“Request Body should be a valid JSON object.” (post /meetings/{meetingId}/registrants)

I want to register users for some meeting base on zoom api. Source is next:

but I cant do it.

my php code is:

<?php $client = Drupal::service('zoomapi.client'); $user = array( "email"=>$udata['uemail'], "first_name"=>stripslashes($udata['ufirstname']), "last_name"=>stripslashes($udata['ulastname']), "address"=>"", "city"=>"", "country"=>"DE", "zip"=>"", "state"=>"", "phone"=>"", "industry"=>"", "org"=>"", "job_title"=>"", "purchasing_time_frame"=>"", "role_in_purchase_process"=>"", "no_of_employees"=>"", "comments"=>"", "custom_questions"=>array(), "language"=>"de-DE" ); $meeting_number = 944876713XX; $response = $client->request('POST', '/meetings/' . $meeting_number . '/registrants', ['headers' => ['Content-Type' => 'application/json'], 'body' =>[ json_encode($dataJson)] ] ); //I tried too, because required is email and firstname $user = array( "email"=>$udata['uemail'], "first_name"=>stripslashes($udata['ufirstname']), "last_name"=>stripslashes($udata['ulastname']), /* "address"=>"", "city"=>"", "country"=>"DE", "zip"=>"", "state"=>"", "phone"=>"", "industry"=>"", "org"=>"", "job_title"=>"", "purchasing_time_frame"=>"", "role_in_purchase_process"=>"", "no_of_employees"=>"", "comments"=>"", "custom_questions"=>array(), "language"=>"de-DE"*/ ); $response = $client->request('POST', '/meetings/' . $meeting_number . '/registrants', $user); ?>

I get this error:
GuzzleHttp\Exception\ClientException : Client error: POST https://api.zoom.us/v2/meetings/94487671384/registrants?headers%5BContent-Type%5D=application%2Fjson&body%5B0%5D=%7B%22email%22%3A%22masteroma%40gmail.com%22%2C%22first_name%22%3A%22Roman%22%2C%22last_name%22%3A%22Bunyak%22%7D resulted in a 400 Bad Request response: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>300Request Body should be a valid JS (truncated…) in GuzzleHttp\Exception\RequestException::create() (line 114 of vendor/guzzlehttp/guzzle/src/Exception/RequestException.php ).

It would be great if you can help me with this.

Thank you!

I have the same error with a curl request, the same request works into postman, I tought about encoding but cannot find the problem

Hi @j.amelsberg,

Do you run into the same error when you try sending this request in Postman? It seems like this could be an issue with your environment.

Can you try sending this using the tool in our documentation and let us know if you still run into the same error—you can test from the bottom of this endpoint’s documentation, and generate a code snippet in various languages:

If you are still seeing an error, can you post the request URL and the raw JSON you’re sending in the request?


Hi @teo.goddet,

If your request is working fine in Postman, it’s likely an issue with your environment/code. Have you tried our code generator tool (see post above)?


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