Hi, I’m new to working with the Zoom API. We’re trying to write a plugin to create a Zoom meeting at the click of a button.
I’ve managed to get POST /users/{userId}/meetings working on Postman using both the userId and ‘me’. This is the body:
{
“topic”: “Name of Course.”,
“userId”: “EMAIL ADDRESS”,
“type”: 2,
“start_time”: “2023-12-12”,
“duration”: 30
}
We now want to get that working in our C# app. Here’s the code I have in Visual Studio. I’ve edited a couple of fields here to PRIVATE to protect data but I believe everything is as it should be, but maybe I’m missing something obvious:
public async Task SetMeeting()
{
string tokenUrl = “https://zoom.us/oauth/token”;
// Your Zoom API credentials
string apiKey = “PRIVATE”;
string apiSecret = “PRIVATE”;
string accessToken = await GetAccessToken(tokenUrl, apiKey, apiSecret);
// API base URL
string baseUrl = "https://api.zoom.us/v2";
// Create the HttpClient
var httpClient = new HttpClient();
httpClient.BaseAddress = new Uri(baseUrl);
httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", accessToken);
httpClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
// Create the request body
var requestBody = new
{
topic = "Name of Course.",
userId = "PRIVATE",
type = 2,
start_time = "2023-12-12",
duration = 30
};
// Convert the body to JSON
string jsonBody = JsonConvert.SerializeObject(requestBody);
// Create the HttpContent
var httpContent = new StringContent(jsonBody, Encoding.UTF8, "application/json");
// Send the POST request
HttpResponseMessage response = await httpClient.PostAsync("/users/me/meetings", httpContent);
// Check if the request was successful
if (response.IsSuccessStatusCode)
{
string jsonResponse = await response.Content.ReadAsStringAsync();
dynamic responseData = JsonConvert.DeserializeObject<dynamic>(jsonResponse);
Console.WriteLine("Meeting created successfully!");
Console.WriteLine("Meeting ID: " + responseData.id);
}
else
{
Console.WriteLine("Failed to create a meeting. Error: " + response.ReasonPhrase);
}
Console.ReadLine();
}
Each time I run the method it gets to the if and errors:
StatusCode: 404, ReasonPhrase: ‘Not Found’, Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
It seems it’s not even finding the endpoint.
I’ve also tried with the userId instead of ‘me’ but no luck.
I believe I’ve enabled the settings specified here too:
But I may have missed something. Any pointers would be great. Thanks.