August 7, 2022

How to create Zoom Meeting with Zoom API using Core Razor Page

How to create Zoom Meeting with Zoom API using Core Razor Page

Here I will explain you step by step on how to create a Zoom Meeting Link with Zoom API using Core Razor Page.

Create Zoom App to get API Key and Secret

To get Zoom API, we need to create an Account on Zoom Marketplace. Click this link to create one.

Zoom Marketplace

Once you created the Zoom account. Go to the Build App page and select the JWT to generate your API Key & Secret.

By using JWT, you don’t need a user authorization and it supports server to server integration.

zoom JWT- techussain
Zoom JWT

You can see the detailed documentation about JWT through this link.

Also see on How to create a Zoom Meeting Link with Zoom API using C# and VB

Now create an Core Razor Page on Visual Studio and name it as ZoomAPI.

Now right click Pages folder on Solution Explorer and add a new Razor Page and name it as Zoom.cshtml

Add the code below on Zoom.cshtml

@model ZoomModel
    ViewData["Title"] = "Create Zoom Meeting";

<h2>Host URL</h2>

<h2>Join URL</h2>

<h2>Response Code</h2>

NuGet Packages needed to run the application.


To install NuGet Packages, right click ZoomAPI from the solution Explorer and click Manage Nuget packages.

Now open the Code Behind and add the code.

Required Namespaces

using Newtonsoft.Json.Linq;
using RestSharp;
using System;
using System.Text;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.IdentityModel.Tokens;
using Microsoft.AspNetCore.Mvc;
using System.Net;

Now BindProperty with the following strings

public string Host { get; set; }
public string Join { get; set; }
public string Code { get; set; }

Now declare the variables

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

Create the Token Descriptor and change it to Token String for the Authorization Header

var tokenDescriptor = new SecurityTokenDescriptor
Issuer = "Your API Key",
Expires = now.AddSeconds(300),
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(symmetricKey), SecurityAlgorithms.HmacSha256),
var token = tokenHandler.CreateToken(tokenDescriptor);
var tokenString = tokenHandler.WriteToken(token);

Create Request

Now use the code for the Request

var client = new RestClient("{userid}/meetings");
var request = new RestRequest(Method.POST);
request.RequestFormat = DataFormat.Json;
request.AddJsonBody(new { topic = "Meeting with Ussain", duration = "10", start_time = "2021-05-20T05:00:00", type = "2" });
request.AddHeader("authorization", String.Format("Bearer {0}", tokenString));

{userid}: you can use your Zoom Username.

host_email: Host Email

topic: Topic for the meeting

duration: Duration of the meeting

start_time: Set the start time for the meeting

type: We use 2 for Scheduled meeting

For more objects like above please refer this link

Here we use DataFormat.Json for format as we created JWT.

Get Response

Now use the code to get the Response

IRestResponse restResponse = client.Execute(request);
HttpStatusCode statusCode = restResponse.StatusCode;
int numericStatusCode = (int)statusCode;
var jObject = JObject.Parse(restResponse.Content);
Host = (string)jObject["start_url"];
Join = (string)jObject["join_url"];
Code = Convert.ToString(numericStatusCode);

That’s it.

Now you can generate the link.



About Author


Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.