While running create api with token working fine in POSTMAN
but when i was trying from web api it is getting 401 not found error.
Hey @meetings1, thanks for posting and using Zoom!
Please share your C# code, as well as the endpoint url, and request body you are using.
Please also share how you are authenticating (JWT or OAuth)?
Thanks,
Tommy
//method for GenerateZoomToken
public string GenerateZoomToken(){
// Token will be good for 20 minutes
DateTime Expiry = DateTime.UtcNow.AddMinutes(20);
string ApiKey = "xyz";//(your apiKey)
string ApiSecret = "abc";//(your ApiSecret)
int ts = (int)(Expiry - new DateTime(1970, 1, 1)).TotalSeconds;
// Create Security key using private key above:
var securityKey = new Microsoft.IdentityModel.Tokens.SymmetricSecurityKey(Encoding.UTF8.GetBytes(ApiSecret));
// length should be >256b
var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);
//Finally create a Token
var header = new JwtHeader(credentials);
//Zoom Required Payload
var payload = new JwtPayload
{
{ "iss", ApiKey},
{ "exp", ts },
};
var secToken = new JwtSecurityToken(header, payload);
var handler = new JwtSecurityTokenHandler();
// Token to String so you can use it in your client
var tokenString = handler.WriteToken(secToken);
return tokenString;
}
[HttpPost]
public ActionResult CreateMeeting(CreateZoomModel ZoomModel)
{
using (var client = new HttpClient())
{
//Here calling GenerateZoomToken method
var token = GenerateZoomToken();
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);
client.BaseAddress = new Uri("https://api.zoom.us/v2/users/{abc@gmail.com}/meetings")
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
var postTask = client.PostAsJsonAsync<object>("meetings", ZoomModel);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
postTask.Wait();
var result = postTask.Result;
if (result.IsSuccessStatusCode)
{
//todo
}
}
return null;
}
We are using JWT authenticating
Requested Body
{
topic: "API Test",
type: 2,
start_time: "2020-08-30T12:00:00Z",
duration: 60,
timezone: "Asia/Calcutta",
password: "abc",
agenda: "Meeting description",
recurrence : {
type: 2,
repeat_interval: 3,
weekly_days: "2",
monthly_day: 2,
monthly_week: 2,
monthly_week_day:2,
end_times: 2,
end_date_time: "2020-08-30T12:00:00Z"
},
settings: {
host_video: false,
participant_video: false,
cn_meeting: false,
in_meeting: false,
join_before_host: false,
mute_upon_entry: false,
watermark: false,
use_pmi: false,
approval_type: 2,
registration_type: 1,
audio:"both",
auto_recording: "local",
enforce_login: false,
enforce_login_domains: "sd",
alternative_hosts: "abc@gmail.com"
},
global_dial_in_countries: [
{
items:"india"
}
],
meeting_authentication: true,
registrants_email_notification: true
};
Hey @meetings1,
Are you actually passing {abc@gmail.com}
in your request?
https://api.zoom.us/v2/users/{abc@gmail.com}/meetings
The email used must be a user on your account.
Thanks,
Tommy
Hi @tommy
Yes we are passing correct emailid. It is working in postman but when i raise a request from c# web api (mvc.net) program it is throwing below exception.For your reference code snippet added in previously.
We are getting BadRequest Error
Also let me know if requested body sent is correct or not.