Issue creating meeting using JWT

I am attempting to create a zoom meeting using C# with JWT authentication.
I can create a meeting using Postman but struggling through my code.
I am getting an empty response back and no meeting is created.

	public String AddZoomMeetingLink(String b)

		var tokenHandler = new System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler();
		var now = DateTime.UtcNow;
		var apiSecret = "mysecret";
		byte[] symmetricKey = Encoding.ASCII.GetBytes(apiSecret);

		var tokenDescriptor = new Microsoft.IdentityModel.Tokens.SecurityTokenDescriptor
			Issuer = "myapikey",
			Expires = now.AddSeconds(30),
			SigningCredentials = new Microsoft.IdentityModel.Tokens.SigningCredentials(new Microsoft.IdentityModel.Tokens.SymmetricSecurityKey(symmetricKey), Microsoft.IdentityModel.Tokens.SecurityAlgorithms.HmacSha256Signature)

		var token = tokenHandler.CreateToken(tokenDescriptor);
		var tokenString = tokenHandler.WriteToken(token);

		JObject jObjectbody = new JObject();
		jObjectbody.Add("topic", "test");
		jObjectbody.Add("duration", "10");
		jObjectbody.Add("start_time", "2021-06-30T05:00:00");
		jObjectbody.Add("type", "2");

		var client = new RestClient("");		
		var request = new RestRequest(Method.POST);
		request.AddHeader("authorization", String.Format("Bearer {0}", tokenString));
		request.AddHeader("content-type", "application/json");
		request.AddParameter("application/json", jObjectbody, ParameterType.RequestBody);
		IRestResponse restResponse = client.Execute(request);
		HttpStatusCode statusCode = restResponse.StatusCode;
		return restResponse.Content;

Any help greatly appreciated

Hi @emjay,

Happy to help! Can you try using this sample below in C# and let me know if it helps? You’ll need to plug in your own token and user ID:

var client = new RestClient("{userId}/meetings");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer {token}");
request.AddParameter("application/json", "{\n  \"topic\": \"Test\",\n  \"start_time\": \"2021-07-17T11:50:00\",\n  \"timezone\": \"Asia/Kolkata\",\n  \"duration\": \"30\",\n  \"type\": 2\n}",  ParameterType.RequestBody);
IRestResponse response = client.Execute(request);


Hi Will, thanks for your reply.

To Fix I had to specify the tls version before my call:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

I turned off Tls 1.0 and Tls 1.1 on my machine but still had to specify the correct version.

Ah, I see—thank you for sharing @emjay :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.