Error while Create Meeting call in C#

Hi All,

I am creating API calls for ZOOM API in C#. If I call CreateMeeting using RestSharp HttpClient it generates me an error unsupported media type ErrorCode:300

Here is my code

var client = new RestClient($"https://api.zoom.us/v2/users/{userId}/meetings");
        var request = new RestRequest(Method.POST);
        
        request.AddHeader("authorization", string.Format("Bearer {0}", tokenString));
        var json = JsonConvert.SerializeObject(new CreateMeetingRequest
        {
            Topic= "Test Meeting",
            Agenda = "Test Meeting",
            Duration = 20,
            Password = "Password",
            Type = Common.MeetingType.InstantMeeting,
            Start_Time = DateTime.Now.ToString()
        });
        
        request.AddParameter("application/json", json);
        IRestResponse response = client.Execute(request);

Hey @ahaq,

Is that error coming from the Zoom API?

Can you log the JSON request body you are sending so I can debug your request?

Thanks,
Tommy

Here is the complete object I am using for the create meeting request

Hey @ahaq,

It looks like you might have tried to attach the request body for your create meeting call, but nothing came through. Can you attach a code snippet or screen shot of the JSON you’re sending along with your create meeting request here?

Thanks, and we’ll keep an eye out!

Best,
Will

Thanks for your time I got my fix :slight_smile:

var client = new RestClient($"https://api.zoom.us/v2/users/{userId}/meetings");
        var request = new RestRequest(Method.POST);
        request.AddHeader("content-type", "application/json");
        request.AddHeader("authorization", string.Format("Bearer {0}", tokenString));

        var json = JsonConvert.SerializeObject(new CreateMeetingRequest
        {
            topic = "Test  Meeting",
            agenda = "Test Meeting",
            duration = 20,
            password = "PAssword",
            type = (int)MeetingType.InstantMeeting,
            start_time = DateTime.UtcNow.ToString("O"),
            recurrence = new Reccurence
            {
                type = 1,
                repeat_interval = 1,
                monthly_day = 1,
                monthly_week = 1,
                monthly_week_day = 1,
                end_date_time = DateTime.UtcNow.ToString("o")
            },
            settings = new Settings
            {
                host_video = true,
                auto_recording = "local",
                waiting_room = true,

            }
        }, new JsonSerializerSettings
        {
            NullValueHandling = NullValueHandling.Ignore,
        });
        request.AddJsonBody(json);
        //request.AddParameter("application/json", json);
        IRestResponse response = client.Execute<CreateMeetingResponse>(request);
1 Like

Thanks for sharing your solution @ahaq! :slight_smile:

-Tommy

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.