Hi. I am trying to create a meeting through the ZOOM API. I am using the api_key and JWT ,token. api returning the response code zero with content null

public ActionResult Index()
{

        var getToken = GenerateToken();
        var client = new RestClient("https://api.zoom.us/v2/users/me/meetings");
        var request = new RestRequest(Method.POST);
        request.RequestFormat = DataFormat.Json;
        request.AddJsonBody(new { topic = "Meeting with Hussain", duration = "10", start_time = "2022-03-20T05:00:00", type = "2" });
        request.AddHeader("content-type", "application/json");
        request.AddHeader("MediaType", "application/json");
        request.AddHeader("Accept", "application/json");
        request.AddHeader("KeepAlive", "true");
        request.AddHeader("Authorization", String.Format("Bearer {0} ", getToken));

        IRestResponse restResponse = client.Execute(request);
        HttpStatusCode statusCode = restResponse.StatusCode;
        int numericStatusCode = (int)statusCode;
        var jObject = JObject.Parse(restResponse.Content);

        ZoomModel model = new ZoomModel();
        model.Host = (string)jObject["start_url"];
        model.Join = (string)jObject["join_url"];
        model.Code = Convert.ToString(numericStatusCode);
        return View(model);
    } 

private string GenerateToken()
{
var tokenHandler = new System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler();
var now = DateTime.UtcNow;
string Apikey = “xxxxxxxxxxxxxxxx”; //Secret key which will be used later during validation
string ApiSecretkey = “xxxxxxxxxxxxxxxx”; //Secret key which will be used later during validation

        byte[] symmetricKey = Encoding.ASCII.GetBytes(ApiSecretkey);

        var tokenDescriptor = new SecurityTokenDescriptor
        {
            Issuer = Apikey,
            Expires = now.AddSeconds(3600),
            SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(symmetricKey), SecurityAlgorithms.HmacSha256),
        };
        var token = tokenHandler.CreateToken(tokenDescriptor);

        var tokenString = tokenHandler.WriteToken(token);
  
        return tokenString;
    }

Hey @tahirhussain858
Thanks for reaching out to the Zoom Developer Forum, I am happy to help here!
Have you tried making a sample call with Postman or Insomia to make sure that you are passing the proper parameters?
Cheers,
Elisa

yes i have test api at https://web.postman.co/ and its return output as I expected

Header


Body

Response

API only working fine when I test it at https://web.postman.co/
and it’s not working in my application and postman application locally, I’m tired.

Hi @tahirhussain858
The only thing that comes to my mind is the way that you are generating the access token.
Could you please check in our documentation if you are following the best practices:

Which Postman Agent are you using to send requests in the Postman web app (which is succeeding for you) versus the local Postman desktop app (which is failing for you)? I wonder if your local environment is trying to intercept the connection in some way (for example, corporate environments tend to want to monitor SSL connection contents).

1 Like

I’m using this method to generate JWT token
public static string ZoomToken()
{
// Token will be good for 20 minutes
DateTime Expiry = DateTime.UtcNow.AddMinutes(30);

        string ApiKey = "zzzzzzzzzzzzzzzzzzzzz";
        string ApiSecret = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";

        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;
    }

IRestResponse response = client.Execute(request) c# return error message The underlying connection was closed: An unexpected error occurred on a send.

Hi! Thanks to all Zoom Dev Team I have found the solution and now the issue is fixed, just Configure ServicePointManager.SecurityProtocol through AppSettings in the project,now zoom meeting created successfully.

1 Like