Hi fellow developers,
I have purchased the Zoom SDK Universal subscription aiming to integrate it in my ASP NET Core web application. And tried so hard to learn how to start using it for creating (or scheduling) meeting links.
The problem is that I tried accessing “Build App”, then use the Api Keys aiming to create a meeting through the a .net Core API but was getting this error:
Error creating meeting: {“code”:200,“message”:“Video SDK Account does not support this REST API.”}
The service code:
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using Jose;
using System.IdentityModel.Tokens.Jwt;
public class ZoomService
{
private readonly HttpClient _httpClient;
private readonly string _apiKey;
private readonly string _apiSecret;
public ZoomService(IConfiguration configuration)
{
_httpClient = new HttpClient();
_apiKey = configuration["Zoom:ApiKey"];
_apiSecret = configuration["Zoom:ApiSecret"];
}
public async Task<string> CreateMeetingAsync()
{
var token = GenerateJwtToken();
_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
_httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var meetingDetails = new
{
topic = "Test Meeting",
type = 1,
start_time = DateTime.UtcNow.AddMinutes(10).ToString("yyyy-MM-ddTHH:mm:ssZ"),
duration = 30,
timezone = "UTC",
agenda = "Test Meeting Agenda"
};
var content = new StringContent(JsonConvert.SerializeObject(meetingDetails), Encoding.UTF8, "application/json");
var response = await _httpClient.PostAsync("https://api.zoom.us/v2/users/me/meetings", content);
var responseString = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode)
{
throw new Exception($"Error creating meeting: {responseString}");
}
return responseString;
}
private string GenerateJwtToken()
{
var now = DateTime.UtcNow;
var exp = now.AddMinutes(30);
var payload = new
{
iss = _apiKey,
exp = new DateTimeOffset(exp).ToUnixTimeSeconds()
};
return JWT.Encode(payload, Encoding.UTF8.GetBytes(_apiSecret), Jose.JwsAlgorithm.HS256);
}
}