Hey, @tommy I’m also trying to write a c# console application that will run and create meetings but it’s not working properly.
As the meeting is created doesn’t show my Topic and instead just Zoom Meeting, Also I’m unable to set the alternate host as It does also not appear in that meeting created and also the time of the meeting is not created correctly.
here is my code:
Meeting request class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Zoom.Sync.Api
{
public class Recurrence
{
[JsonPropertyName(“type”)]
public string Type;
[JsonPropertyName("repeat_interval")]
public string RepeatInterval;
[JsonPropertyName("weekly_days")]
public string WeeklyDays;
[JsonPropertyName("monthly_day")]
public string MonthlyDay;
[JsonPropertyName("monthly_week")]
public string MonthlyWeek;
[JsonPropertyName("monthly_week_day")]
public string MonthlyWeekDay;
[JsonPropertyName("end_times")]
public string EndTimes;
[JsonPropertyName("end_date_time")]
public string EndDateTime;
}
public class Settings
{
[JsonPropertyName("host_video")]
public string HostVideo;
[JsonPropertyName("participant_video")]
public string ParticipantVideo;
[JsonPropertyName("cn_meeting")]
public string CnMeeting;
[JsonPropertyName("in_meeting")]
public string InMeeting;
[JsonPropertyName("join_before_host")]
public string JoinBeforeHost;
[JsonPropertyName("mute_upon_entry")]
public string MuteUponEntry;
[JsonPropertyName("watermark")]
public string Watermark;
[JsonPropertyName("use_pmi")]
public string UsePmi;
[JsonPropertyName("approval_type")]
public string ApprovalType;
[JsonPropertyName("registration_type")]
public string RegistrationType;
[JsonPropertyName("audio")]
public string Audio;
[JsonPropertyName("auto_recording")]
public string AutoRecording;
[JsonPropertyName("enforce_login")]
public string EnforceLogin;
[JsonPropertyName("enforce_login_domains")]
public string EnforceLoginDomains;
[JsonPropertyName("alternative_hosts")]
public string AlternativeHosts;
[JsonPropertyName("global_dial_in_countries")]
public List<string> GlobalDialInCountries;
[JsonPropertyName("registrants_email_notification")]
public string RegistrantsEmailNotification;
}
public class Meeting
{
[JsonPropertyName("topic")]
public string Topic;
[JsonPropertyName("type")]
public string Type;
[JsonPropertyName("start_time")]
public string StartTime;
[JsonPropertyName("duration")]
public string Duration;
[JsonPropertyName("schedule_for")]
public string ScheduleFor;
[JsonPropertyName("timezone")]
public string Timezone;
[JsonPropertyName("password")]
public string Password;
[JsonPropertyName("agenda")]
public string Agenda;
[JsonPropertyName("recurrence")]
public Recurrence Recurrence;
[JsonPropertyName("settings")]
public Settings Settings;
}
}
Meeting Response class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Zoom.Sync.Api.Models
{
public class ApprovedOrDeniedCountriesOrRegions
{
public bool enable { get; set; }
public string method { get; set; }
public List<object> approved_list { get; set; }
public List<object> denied_list { get; set; }
}
public class Settings
{
public bool host_video { get; set; }
public bool participant_video { get; set; }
public bool cn_meeting { get; set; }
public bool in_meeting { get; set; }
public bool join_before_host { get; set; }
public bool mute_upon_entry { get; set; }
public bool watermark { get; set; }
public bool use_pmi { get; set; }
public int approval_type { get; set; }
public int registration_type { get; set; }
public string audio { get; set; }
public string auto_recording { get; set; }
public bool enforce_login { get; set; }
public string enforce_login_domains { get; set; }
public string alternative_hosts { get; set; }
public bool close_registration { get; set; }
public bool waiting_room { get; set; }
public List<object> global_dial_in_countries { get; set; }
public List<object> global_dial_in_numbers { get; set; }
public string contact_name { get; set; }
public string contact_email { get; set; }
public bool registrants_confirmation_email { get; set; }
public bool registrants_email_notification { get; set; }
public bool meeting_authentication { get; set; }
public string authentication_option { get; set; }
public string authentication_domains { get; set; }
public string authentication_name { get; set; }
public List<object> interpreters { get; set; }
public bool show_share_button { get; set; }
public bool allow_multiple_devices { get; set; }
public string encryption_type { get; set; }
public ApprovedOrDeniedCountriesOrRegions approved_or_denied_countries_or_regions { get; set; }
}
public class Recurrence
{
public int type { get; set; }
public int repeat_interval { get; set; }
public string weekly_days { get; set; }
public int monthly_day { get; set; }
public int monthly_week { get; set; }
public int monthly_week_day { get; set; }
public int end_times { get; set; }
public string end_date_time { get; set; }
}
public class Meeting
{
public long id { get; set; }
public string assistant_id { get; set; }
public string host_email { get; set; }
public string registration_url { get; set; }
public string topic { get; set; }
public int type { get; set; }
public string start_time { get; set; }
public int duration { get; set; }
public string timezone { get; set; }
public string created_at { get; set; }
public string agenda { get; set; }
public string start_url { get; set; }
public string join_url { get; set; }
public string password { get; set; }
public string h323_password { get; set; }
public int pmi { get; set; }
public List<object> tracking_fields { get; set; }
public List<object> occurrences { get; set; }
public Settings settings { get; set; }
public Recurrence recurrence { get; set; }
}
}
and the Program class
using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json;
using RestSharp;
using System;
using System.Collections.Generic;
using System.Text;
namespace Zoom.Sync.Api
{
class Program
{
static void Main(string args)
{
var tokenHandler = new System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler();
var now = DateTime.UtcNow;
var apiSecret = “API SECRET”;
byte symmetricKey = Encoding.ASCII.GetBytes(apiSecret);
var tokenDescriptor = new SecurityTokenDescriptor
{
Issuer = "API Key",
Expires = now.AddSeconds(60),
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(symmetricKey), SecurityAlgorithms.HmacSha256),
};
var token = tokenHandler.CreateToken(tokenDescriptor);
var tokenString = tokenHandler.WriteToken(token);
Meeting iMeeting = new Meeting();
iMeeting.Topic = $"Test Zoom Meeting Created By Sync App {Environment.MachineName}";
iMeeting.Type = "2";
//iMeeting.Timezone = "Asia/Jerusalem";
iMeeting.StartTime = DateTime.Now.AddHours(8).ToString("yyyy-MM-ddTHH:mm:ss");
iMeeting.Duration = "60";
Settings iMeetingSettings = new Settings();
iMeetingSettings.AlternativeHosts = "meeting-alternate-hostmail@mydomain.com";
iMeetingSettings.HostVideo = "true";
iMeetingSettings.JoinBeforeHost = "fasle";
iMeetingSettings.MuteUponEntry = "true";
iMeetingSettings.Audio = "both";
iMeetingSettings.AutoRecording = "cloud";
iMeetingSettings.GlobalDialInCountries = new List<string>() { "IL", "US" };
iMeeting.Settings = idcMeetingSettings;
var client = new RestClient("https://api.zoom.us/v2/users/meetinghostmail@mydomain.com/meetings");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", String.Format("Bearer {0}", tokenString));
request.AddJsonBody(iMeeting);
IRestResponse response = client.Execute(request);
if(response.StatusCode == System.Net.HttpStatusCode.Created)
{
Console.WriteLine(response.Content);
Zoom.Sync.Api.Models.Meeting createdMeeting = JsonConvert.DeserializeObject<Zoom.Sync.Api.Models.Meeting>(response.Content);
Console.WriteLine($"ID: {createdMeeting.id} --> Join Url: {createdMeeting.join_url}");
}
Console.ReadLine();
}
}
}
What am I missing?
My meeting time should be at Jerusalem Time Zone, and my user’s emails exist under our organization account.
Looking forward to your reply,
Thanks,
Hagai.