Invoke-WebRequest ; Request Body should be a valid JSON object

Using PowerShell, the following JSON formatting works for a create user ;

      $CreateZoomUserJSON = "
        'action': 'ssoCreate',
$Body = $CreateZoomUserJSON -replace '''','"'
Invoke-RestMethod "" -Headers  @{ Authorization = "Bearer $Accesstoken" } -Body ($Body) -Method Post -ContentType 'application/json'

However, when attempting the same formatting to provision a phone user, I get the error mentioned in the title;

$SetPlan = "
  $Body = $SetPlan -replace '''','"'
  Invoke-RestMethod "" -Headers  @{ Authorization = "Bearer $Accesstoken" } -Body ($Body) -Method Post -ContentType 'application/json'

With the error shown below

Invoke-RestMethod : {“code”:300,“message”:“Request Body should be a valid JSON object.”}
At line:79 char:3
+ Invoke-RestMethod "
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

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

Which Endpoint/s?
Shown above in description

How To Reproduce (If applicable)
Steps to reproduce the behavior:
Attempt the same formatting on Powershell when attempting to assign a calling plan/number/ext.

Hi @snimmo,

It looks like you might be missing some square brackets [ ] — see below:

Let me know if that resolves the issue.


@will.zoom I tried that and I’m 90% sure it gave me the same error but after the brackets were added now it’s saying it can’t find the user (so hurray it works!).

However, I’m kinda confused on just what I need to do from an API perspective on how I should get a phone user provisioned. More so, what order of events need to occur to assign a user to a site with a calling plan/ext?

Hi @snimmo,

Once a user has the appropriate plan allocated to their profile and a Zoom Phone License, you should be able to assign them a phone number using this endpoint:


@will.zoom ,

To make sure I got it (sorry for the slashes, it won’t let me post more than 2 links);

  1. Create a user here ; //
  2. Set a calling plan here ; //
  3. After getting available numbers at their site, assign them a number ; //
  4. Then set extension here ; //

Hey @snimmo,

That looks good! After you create a user however, make sure you’ve assigned them a Zoom Phone license before step 2. This is applied using the feature object from this endpoint:


1 Like

@will.zoom , Awesome. I was able to update everything accordingly and get a few test accounts spun up and verified working.

Thank you for the assist!

Awesome, glad I could help! :slight_smile:

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