C# ScheduleEventService.get

Hello!

Noob to this forum, API programming and Kaltura. Having a hard time implementing the following sample code to return a XML Object type of KalturaScheduleEvent Recurrance as returned by Kaltura - Test Me Console
when set to service of ScheduleEvent and action of get


using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Kaltura{

class CodeExample{

static void Main(string[] args){

KalturaConfiguration config = new KalturaConfiguration(partnerId);
config.ServiceUrl = "http://www.kaltura.com/";
KalturaClient client = new KalturaClient(config);

int scheduleEventId = 11850853;

Object result = client.ScheduleeventService.Get(scheduleEventId);

I have downloaded the KalturaGeneratedAPIClientsCSharp.tar.gz from the Kaltura site, opened the solution in visual Studio and browsed the code.

This code seems to get a connection. I need help with how to read in the XML result so that I can print to the console.

Client client = new Client(GetConfig());
client.KS = client.GenerateSession(PARTNER_ID, ADMIN_SECRET, USER_ID, SessionType.ADMIN, 86400, "");

string id = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 20);
uniqueTag = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 20);

Console.WriteLine("Starting C# Kaltura API Client Library");
           
int scheduleEventId = 11850853;

ScheduleEventGetRequestBuilder result = ScheduleEventService.Get(scheduleEventId);
           
Console.WriteLine(ScheduleEventGetRequestBuilder.Deserialize(result));

Once I can print to console, I can continue with my programming. My ultimate goal is to get the TemplateEntryID from the return of the ScheduleEventService.get and call Media.get for the status.

Thank you in advance for the assistance

Hello @eberfinn ,

The Kaltura - Test Me Console code generator is obsolete.
Please use https://developer.kaltura.com/console/service/scheduleEvent/action/get instead.
Be sure to use this version of the client: https://github.com/kaltura/KalturaGeneratedAPIClientsCsharp/archive/v17.5.0.tar.gz

If the execution fails, please provide the full code (masking any secrets of course) and the output (including the stack trace) and I’ll assist you further.

Thanks,

Using sample code from developer kaltura com/api-docs /service /scheduleEvent /action /list (sorry forum is thinking stack trace below has links)
with the 17.5 version of the C# Kaltura library from your previous post

It is giving System.Net.HttpRequestException, code followed by stack trace below.
I filled the following fields in the createKalturaClient method:
partnerId, secret, and userID
The secret worked for the developer console before and after this code failed.
How can I troubleshoot this problem further?
Does the privileges field need to be not null?
Thank you

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Kaltura;
using Kaltura.Enums;
using Kaltura.Types;
using Kaltura.Request;
using Kaltura.Services;
using System.Threading;

namespace Kaltura
{
    class CodeExample
    {
        static void Main(string[] args)
        {
            Client client = CodeExample.createKalturaClient();
            bool done = false;
            ScheduleEventFilter filter = new ScheduleEventFilter();
            filter.IdEqual = 4287721;
            FilterPager pager = new FilterPager();
           
                OnCompletedHandler<ListResponse<ScheduleEvent>> handler = new OnCompletedHandler<ListResponse<ScheduleEvent>>(
                      (ListResponse<ScheduleEvent> result, Exception e) =>
                      {

                          CodeExamplPrintObject(result);
                          done = true;
                      });
                ScheduleEventService.List(filter, pager)
                   .SetCompletion(handler)
                   .Execute(client);
            
         

            while (!done)
            {
                Thread.Sleep(100);
            }
            }

            static Client createKalturaClient()
            {
                Configuration config = new Configuration();
                config.ServiceUrl = "https://www.kaltura.com/";
                Client client = new Client(config);
                int partnerId = 2007921;
                string secret = "";
                string userId = "";
                SessionType type = SessionType.ADMIN;
                int expiry = 86400;
                string privileges = "";
                client.KS = client.GenerateSession(partnerId, secret, userId, type, expiry, privileges);
                return client;
            }

            public static void PrintObject<T>(T obj)
            {
                var t = typeof(T);
                var props = t.GetProperties();
                StringBuilder sb = new StringBuilder();
                foreach (var item in props)
                {
                    try
                    {
                        sb.Append(item.Name + ": " + item.GetValue(obj, null) + "\n");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                }
                sb.AppendLine();
                Console.WriteLine(sb.ToString());
            }
        }
    }

‘KalturaClientTester.exe’ (CLR v4.0.30319: DefaultDomain): Loaded ‘C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll’.
‘KalturaClientTester.exe’ (CLR v4.0.30319: DefaultDomain): Loaded ‘C:\Users\whampt\Downloads\KalturaGeneratedAPIClientsCsharp-17.5.0\KalturaClientTester\bin\Debug\net45\KalturaClientTester.exe’. Symbols loaded.
‘KalturaClientTester.exe’ (CLR v4.0.30319: KalturaClientTester.exe): Loaded ‘C:\Users\whampt\Downloads\KalturaGeneratedAPIClientsCsharp-17.5.0\KalturaClientTester\bin\Debug\net45\KalturaClient.dll’. Symbols loaded.
‘KalturaClientTester.exe’ (CLR v4.0.30319: KalturaClientTester.exe): Loaded ‘C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll’.
‘KalturaClientTester.exe’ (CLR v4.0.30319: KalturaClientTester.exe): Loaded ‘C:\Windows\Microsoft. Net\assembly\GAC_MSIL\System.Net.Http\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Net.Http.dll’.
‘KalturaClientTester.exe’ (CLR v4.0.30319: KalturaClientTester.exe): Loaded ‘C:\Windows\Microsoft. Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll’.
‘KalturaClientTester.exe’ (CLR v4.0.30319: KalturaClientTester.exe): Loaded ‘C:\Windows\Microsoft. Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll’.
‘KalturaClientTester.exe’ (CLR v4.0.30319: KalturaClientTester.exe): Loaded ‘C:\Windows\Microsoft. Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll’.
Exception thrown: ‘System.Net.Sockets.SocketException’ in System.dll
Exception thrown: ‘System.IO.IOException’ in System.dll
Exception thrown: ‘System.IO.IOException’ in System.dll
Exception thrown: ‘System.IO.IOException’ in System.dll
Exception thrown: ‘System.IO.IOException’ in System.dll
Exception thrown: ‘System.IO.IOException’ in System.dll
Exception thrown: ‘System.ObjectDisposedException’ in System.dll
Exception thrown: ‘System.Net.Sockets.SocketException’ in System.dll
Exception thrown: ‘System.IO.IOException’ in System.dll
Exception thrown: ‘System.IO.IOException’ in System.dll
Exception thrown: ‘System.IO.IOException’ in System.dll
Exception thrown: ‘System.IO.IOException’ in System.dll
Exception thrown: ‘System.IO.IOException’ in System.dll
Exception thrown: ‘System.ObjectDisposedException’ in System.dll
Exception thrown: ‘System.Net.WebException’ in System.dll
Exception thrown: ‘System.Net.Http.HttpRequestException’ in mscorlib.dll
Exception thrown: ‘System.Net.Http.HttpRequestException’ in KalturaClient.dll
Exception thrown: ‘System.Reflection.TargetException’ in mscorlib.dll
Exception thrown: ‘System.Reflection.TargetException’ in mscorlib.dll
Exception thrown: ‘System.Reflection.TargetException’ in mscorlib.dll
Exception thrown: ‘System.Reflection.TargetException’ in mscorlib.dll
The program ‘[29676] KalturaClientTester.exe’ has exited with code 0 (0x0).

An error occurred while sending the request.
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
   at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
   --- End of inner exception stack trace ---
   at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult)
   at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
   at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)
   --- End of inner exception stack trace ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Kaltura.Request.BaseRequestBuilder`1.<ExecuteAsync>d__22.MoveNext()
System.Reflection.TargetException: Non-static method requires a target.
   at System.Reflection.RuntimeMethodInfo.CheckConsistency(Object target)
   at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
   at Kaltura.CodeExample.PrintObject[T](T obj)
System.Reflection.TargetException: Non-static method requires a target.
   at System.Reflection.RuntimeMethodInfo.CheckConsistency(Object target)
   at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
   at Kaltura.CodeExample.PrintObject[T](T obj)
System.Reflection.TargetException: Non-static method requires a target.
   at System.Reflection.RuntimeMethodInfo.CheckConsistency(Object target)
   at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
   at Kaltura.CodeExample.PrintObject[T](T obj)
System.Reflection.TargetException: Non-static method requires a target.
   at System.Reflection.RuntimeMethodInfo.CheckConsistency(Object target)
   at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
   at Kaltura.CodeExample.PrintObject[T](T obj)



C:\Users\whampt\Downloads\KalturaGeneratedAPIClientsCsharp-17.5.0\KalturaGeneratedAPIClientsCsharp-17.5.0\KalturaClientTester\bin\Debug\net45\KalturaClientTester.exe (process 31664) exited with code 0.
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .

I was using the secret from Kaltura - Test Me Console instead of https://developer.kaltura.com/console
which is I was unable to get a session.