Creating Meeting with httpclient getting Message 400 Bad Request

I’m working with the example from Zoom Developer Postman examples for creating meetings. I can get a bearer token using OAuth and use is in the Auth section in Postman. Below is the C# httpclient code created by postman. I know the Bad Request typically means bad JSON, but the below is just taking the example code and adjusting. I have also tried the url using email address also.

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, “https://api.zoom.us/v2/users/me/meetings”);
request.Headers.Add(“Authorization”, “Bearer eyJzdiI6IjAwMDAwMSIsImFsZyI6IkhTNTEyIiwidiI6IjIuMCIsImtpZCI6ImQwZGQ4YjFlLTE1NTEtND1Ny1iYTM2LTYwOGE2YWZhZGQ5YSJ9.eyJhdWQiOiJodHRwczovL29hdXRoLnpvb20udXMiLCJ1aWQiOiJlaTF6QzFYWlR0S0RVRkV1TVpYaTVBIiwidmVyIjo5LCJhdWlkIjoiMDQxMTEyNThjNzcwMWM3ZGRjZGE2ZmMxZGU1NzFiYjIiLCJuYmYiOjE2ODE4NzEzNDksImNvZGUiOiJ6MG92ajN1R1NSQzlSaFphNmRxSFF3Rm1UNERkV2Q5WFMiLCJpc3MiOiJ6bTpjaWQ6aUVpUFlDVGJUZzZxSlVmWlR0X0JTdyIsImdubyI6MCwiZXhwIjoxNjgxODc0OTQ5LCJ0eXBlIjozLCJpYXQiOjE2ODE4NzEzNDksImFpZCI6IlBVVDhzOHB0VGJpR2FiVVRTQ0tMbHcifQ.b0M6ZH7EIGYxglmcS1B7wBaMMtJNr_YhNNq_rg2Y-gzNDp-ZiRIolYkPkJNKPiaw8Fw_y37NupjHUZ3rQg0E-A”);
var content = new StringContent(“{\n "agenda": "My Meeting",\n "duration": 60,\n "start_time": "2022-04-19T07:32:55Z",\n "topic": "My Meeting",\n "type": 2\n}”, null, “application/json”);
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();

Some difference I’ve realised

  • there are missing headers in your bearer token
  • content type should be set to “application/json” in the request header

Thank you for the response. I believe the content type is being set in this line:

var content = new StringContent(“{\n “agenda”: “My Meeting”,\n “duration”: 60,\n “start_time”: “2022-04-19T07:32:55Z”,\n “topic”: “My Meeting”,\n “type”: 2\n}”, null, “application/json”);

If I switch the language in Postman to something other than C# httpclient it does show the request.AddHeader(“Content-Type”, “application/json”).

I’m not exactly sure what your image is showing me here. This is my first attempt and Zoom, so be gentle LOL.

I changed accounts and used this Zoom video (How to create and use a Server to Server OAuth app - YouTube) to recreate Server to Server OAuth. It works fine and I get the bearer token. I used the bearer token to get Userid info and that worked. I then setup the Create Meeting as shown in the video, validated the body JSON, and still am getting 400 Bad Request response:

Here is the Postman code for RestSharp:

var options = new RestClientOptions(“https://api.zoom.us”)
{
MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest(“/v2/users/me/meetings”, Method.Post);
request.AddHeader(“Accept”, “application/json”);
request.AddHeader(“Content-Type”, “application/json”);
request.AddHeader(“Authorization”, “Bearer eyJzdiI6IjAwMDAwMSIsImFsZyI6IkhTNTEyIiwidiI6IjIuMCIsImtpZCI6Ijk2YTRhYmZjLTdhNjgtNDhlZi05M2U2LTI3MDcwMmUyMTAzMSJ9.eyJhdWQiOiJodHRwczovL29hdXRoLnpvb20udXMiLCJ1aWQiOiI2cF9neUNEU1I4Q2xnY0hBNHZqUE13IiwidmVyIjo5LCJhdWlkIjoiYjkyOTUzZGViYTc2YmVmMjY1MmJjOTRmN2YxODZlNDYiLCJuYmYiOjE2ODIwMTEyOTIsImNvZGUiOiJvQlhKZTYxOFNJeTY2VkFVcjZUNHVBejVudkJaU0tPVjYiLCJpc3MiOiJ6bTpjaWQ6bjluV1pYblZSU2VfcFV5MnZpT3pJdyIsImdubyI6MCwiZXhwIjoxNjgyMDE0ODkyLCJ0eXBlIjozLCJpYXQiOjE2ODIwMTEyOTIsImFpZCI6Inp1Ukw0NDBxU2NPcmU3Z0RjX2xvR1EifQ.fcstsmVupRDcUY5OThiAu0mzFaDutFPF31CzyAXXNLsDs69njvJJjclCcTxMIIHbaplyw4bEfIRScM6dTf4jng”);
var body = @“{
" + “\n” +
@” ““topic””: ““Testing 01"”,
" + “\n” +
@” ““type””: 2,
" + “\n” +
@" ““start_time””: ““2023-04-20T05:02:00Z””,
" + “\n” +
@" ““duration””: ““60"”,
" + “\n” +
@” ““timezone””: ““American/Mexico_City””,
" + “\n” +
@" ““password””: ““123"”,
" + “\n” +
@” ““agenda””: ““Testing Testing””,
" + “\n” +
@" ““settings””: {
" + “\n” +
@" ““host_video””: ““true””,
" + “\n” +
@" ““participant_video””: ““true””,
" + “\n” +
@" ““join_before_host””: ““true””
" + “\n” +
@" }
" + “\n” +
@“}”;
request.AddStringBody(body, DataFormat.Json);
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);