Thanks for the responses both. I’ve got it working, but by hard coding in the access token I obtained via Postman as a string…
So ‘me’ did actually work in the endpoint URL. Also yeah, I’d just chosen suboptimal names for my variables but they were the client ID and client secret all along. Yes, I’m trying to use a Server to Server Oauth app to generate the access token
So here’s how the method looks right now. PRIVATE used again in place of certain things.
public async Task SetMeeting()
{
string clientID = “PRIVATE”;
string clientSecret = “PRIVATE”;
string tokenUrl = “https://zoom.us/oauth/token”;
string accessToken = "PRIVATE";
// API base URL
string baseUrl = "https://api.zoom.us/v2";
// Create the HttpClient
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
// Create the request body
var requestBody = new
{
topic = "Name of Course.",
userId = "me",
type = 2,
start_time = "2023-12-12",
duration = 30
};
// Convert the body to JSON
string json = JsonConvert.SerializeObject(requestBody);
var content = new StringContent(json);
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
var createMeetingUrl = $"{baseUrl}/users/me/meetings";
// Send the POST request
var response = await httpClient.PostAsync(createMeetingUrl, content);
// Check if the request was successful
if (response.IsSuccessStatusCode)
{
var result = await response.Content.ReadAsStringAsync();
// Parse the JSON response to get the meeting details
// You can retrieve the join URL, meeting ID, and other information from the response
return result;
}
// Handle error when unable to create the meeting
return "Failed to create meeting";
}
And I followed these instructions to get my access token in Postman (Guide: Making a Zoom API Call with OAuth Credentials in Postman), which would make it of grant type: authorization code, right?