Get Bad request (status 400) using JWT Token in call to API

Description

I am using JWT Auth.

The same token I use connects ok on a GET. When I use the same token on a POST later in my code I get the following error.

I am within a .NET WinService using HttpRequest methods.

The request is:

{Method: POST, RequestUri: ‘https://api.zoom.us/v2/users/{ user }/meetings’, Version: 1.1, Content: PieceBook.Library.NET.Zoom.JsonContent, Headers:
{
Accept: application/json
Authorization: Bearer { token }
Content-Type: application / json; charset=utf-8
Content-Length: 963
}}

Error

{StatusCode: 400, ReasonPhrase: ‘’, Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Connection: keep-alive
x-zm-trackingid: WEB_8c20192beaa66678fc05b908eff2e58f
X-Content-Type-Options: nosniff
Pragma: no-cache
Cache-Control: no-store, no-transform, must-revalidate, no-cache
Date: Wed, 15 Apr 2020 03:30:51 GMT
Set-Cookie: zm_aid=""; Domain=.zoom . us; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; Secure; HttpOnly
Set-Cookie: zm_haid=""; Domain=.zoom . us; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; Secure; HttpOnly
Set-Cookie: cred=CC8625D1ECE8CF392DE6F0C383A0D8B8; Path=/; Secure; HttpOnly
Set-Cookie: _zm_ctaid=""; Domain=.zoom . us; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; Secure; HttpOnly
Set-Cookie: _zm_chtaid=""; Domain=.zoom . us; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; Secure; HttpOnly
Server: ZOOM
Content-Length: 109
Content-Type: application / json; charset=UTF-8
Expires: Thu, 01 Jan 1970 00:00:00 GMT
}}

Which App Type (OAuth / Chatbot / JWT / Webhook)?
JWT

Which Endpoint/s?
Please see above

How To Reproduce (If applicable)
You could try the token I supplied above…

Screenshots (If applicable)
N/a at this stage

Additional context
Please note the JWT token gets existing meetings on same endpoint, just not posting a new scheduled meeting :slight_smile:

Hi @hkdave95, we’ll help you figure this out but I wanted to quickly note I’ve edited your post to remove some personal data.

@hkdave95, could you provide us with the body of the request you’re making?

Are you generating JWT on each request? (this is suggested)

Dear Michael

I thought I should not put some of that out / much obliged….

Quite a lot of things on my list as you might imagine.

Appreciate the help.

KR

David

Actually I tried both methods…

  1. Generating for first Get which works, then following bit of code Post same JWT access token.

  2. Then I tried generated new access token for 2nd call (Post)

  3. In both methods Get works and post does not.

KR

Httprequest…

    public async static Task<PieceBook.Library.NET.Zoom.JWTData.CreatedMeeting> ScheduleMeeting(string lsEndPoint, string lsAccessToken, PieceBook.Library.NET.Data.PieceBook.CalendarItem loCalendarItem, string lsEmail, string lsName, string lsPassword)

{

        PieceBook.Library.NET.Zoom.JWTData.CreatedMeeting loCreatedMeeting = null;

        try

{

            PieceBook.Library.NET.Zoom.JWTData.CreateAMeeting loCreateAMeeting = new JWTData.CreateAMeeting();

            loCreateAMeeting.created_at = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ssZ");

            loCreateAMeeting.start_time = loCalendarItem.Start.ToString("yyyy-MM-ddTHH:mm:ssZ");

            loCreateAMeeting.duration = (int)(loCalendarItem.End - loCalendarItem.Start).TotalMinutes;

loCreateAMeeting.topic = loCalendarItem.Title;

loCreateAMeeting.agenda = loCalendarItem.Description;

loCreateAMeeting.host_id = lsEmail;

loCreateAMeeting.password = lsPassword;

loCreateAMeeting.type = 2;

            loCreateAMeeting.settings.close_registration = false;

loCreateAMeeting.settings.contact_email = lsEmail;

loCreateAMeeting.settings.contact_name = lsName;

            loCreateAMeeting.settings.enforce_login = false;

            loCreateAMeeting.settings.host_video = true;

            loCreateAMeeting.settings.in_meeting = true;

            loCreateAMeeting.settings.join_before_host = false;

            loCreateAMeeting.settings.meeting_authentication = true;

            loCreateAMeeting.settings.mute_upon_entry = false;

            loCreateAMeeting.settings.participant_video = true;

            loCreateAMeeting.settings.registrants_email_notification = false;

loCreateAMeeting.settings.registration_type = 2;

            loCreateAMeeting.settings.use_pmi = false;

            loCreateAMeeting.settings.waiting_room = false;

            HttpRequestBuilder loHttpRequestBuilder = new HttpRequestBuilder();

loHttpRequestBuilder.AddBearerToken(lsAccessToken);

            loHttpRequestBuilder.AddRequestUri(lsEndPoint + string.Format("/users/{0}/meetings", PieceBook.Library.NET.Classes.Encryption.UrlEncode(lsEmail)));

loHttpRequestBuilder.AddMethod(HttpMethod.Post);

JToken json = JObject.FromObject(loCreateAMeeting);

            loHttpRequestBuilder.AddContent(new JsonContent(json));

            HttpResponseMessage loHttpResponseMessage = await loHttpRequestBuilder.SendAsync();

            if (loHttpResponseMessage.IsSuccessStatusCode)

{

loCreatedMeeting = HttpResponseExtensions.ContentAsType<PieceBook.Library.NET.Zoom.JWTData.CreatedMeeting>(loHttpResponseMessage);

}

}

        catch (Exception loException)

{

            PieceBook.Library.NET.Classes.Utility.MakeExceptionMessage(loException, "<br /><br />", "JWTLib.cs -> ScheduleMeeting");

}

        return loCreatedMeeting;

}

Hey @hkdave95,

There is something wrong with your request body.

To make it easier for me to debug, can you reproduce this in Postman, and share your request body in JSON format?

Or just recreate your request body in JSON format.

Thanks,
Tommy

Dear Tommy

Here is the JSON….

Would the null values cause a problem?

David

{{

“host_id”: “david@dar-jader.com”,

“topic”: “Event 7”,

“type”: 2,

“start_time”: “2020-03-09T18:00:00Z”,

“duration”: 120,

“password”: “ipsa”,

“timezone”: null,

“created_at”: “2020-04-16T10:08:25Z”,

“agenda”: “Event 7”,

“tracking_fields”: ,

“recurrence”: {

“type”: 0,

“repeat_interval”: 0,

“weekly_days”: null,

“monthly_day”: 0,

“monthly_week”: 0,

“monthly_week_day”: 0,

“end_times”: 0,

“end_date_time”: null

},

“settings”: {

“host_video”: true,

“participant_video”: true,

“cn_meeting”: false,

“in_meeting”: true,

“join_before_host”: false,

“mute_upon_entry”: false,

“use_pmi”: false,

“approval_type”: 0,

“registration_type”: 2,

“audio”: null,

“audio_recording”: null,

“enforce_login”: false,

“enforce_login_domains”: null,

“alternative_hosts”: null,

“close_registration”: false,

“waiting_room”: false,

“global_dial_in_countries”: null,

“contact_name”: “David.Robertson”,

“contact_email”: “david@dar-jader.com”,

“registrants_email_notification”: false,

“meeting_authentication”: true,

“authentication_option”: null,

“authentication_domains”: null

}

}}

Hey @hkdave95,

Yes, for the null values, just remove that whole key value pair.

Thanks,
Tommy

OK / I shall do so and report back…

Dear Tommy

Found the problem.

I created a recurring event for just one event and the problem dissolved.

I suppose I could simply have removed the unnecessary item from the json data.

Anyhoo it is working now.

TYVM for pointers.

KR

David

1 Like

Happy to hear you got it working! :slight_smile:

-Tommy