title: OneLogin REST API with PowerShell's Invoke-RestMethod
body: <p>I'm working against the OneLogin REST API and can't seem to get any calls with a PUT method working. When I test in Postman, I can pass a raw JSON body like this:</p>
  
  <pre><code>{
     "role_id_array":  [
                          115028
                       ]
  }
  </code></pre>
  
  <p>to the endpoint:</p>
  
  <p><a href="https://api.us.onelogin.com/api/1/users/" rel="nofollow">https://api.us.onelogin.com/api/1/users/</a>/add_roles</p>
  
  <p>This works just fine. However, when I attempt to do the same with PowerShell's Invoke-RestMethod command, I'm getting 400 Bad Request errors. My code looks like this:</p>
  
  <pre><code>$Splat = @{
      Method      = $Method
      Uri         = https://api.us.onelogin.com/api/1/users/12345678/add_roles
      ContentType = "application/json"
      Headers     = @{authorization = "bearer:$($Token.access_token)"}
      Body        = @{role_id_array = @(123456)}
  }
  
  Invoke-RestMethod @Splat
  </code></pre>
  
  <p>So far I've had no issues with any GET calls, only with PUT. Also, if I run the Body hashtable that I'm passing in through ConvertTo-Json, the output looks just like the above working example. Does anyone have any thoughts on why this doesn't work?</p>