I have 2 bits of code in play here. The first creates a Jason Web Token. It works fine. I have a second, working bit of code that can pull back a userlist from our Zoom instance no problem with the JWT code. However, trying to add a new user is throwing weird errors
$token = Get-MyJWT -Algorithm ‘HS256’ -type ‘JWT’ -Issuer -SecretKey -ValidforSeconds 30
$headers = @{“Authorization” = “Bearer $token” }
$body = @"
{
“action”: “create”,
“user_info”: {
“email”: “$email”,
“type”: “2”,
“first_name”: “$firstname”,
“last_name”: “$lastname”,
“password”: “$defaultpass”
}
}
"@ | ConvertFrom-Json
$returncode = Invoke-RestMethod -Headers $headers -Method Post -Uri https://api.zoom.us/v2/users -Body $body -ContentType ‘application/json’
When I run that I get back an error 300. However when I interrogate the $Error object, it says I really got back an error 400 about invalid json body. What am I doing wrong here?
Example output:
Invoke-RestMethod : {“code”:300,“message”:“Request Body should be a valid JSON object.”}
Response : StatusCode: 400, ReasonPhrase: ‘Bad Request’, Version: 1.1, Content: System.Net.Http.HttpConnection+HttpConnectionResponseContent, Headers:…