title: Mimic a Postman request with PowerShell fails
body: <p>I am trying to set permissions for a specific SharePoint site via Graph API. In postman I do following:
  <a href="https://i.stack.imgur.com/Kj7PT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Kj7PT.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/4OF0o.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4OF0o.png" alt="enter image description here" /></a></p>
  <p>And that works. However when I try to do same in PowerShell I get bad request:</p>
  <pre><code>cls
  
  # https://docs.microsoft.com/en-us/graph/api/site-get-permission?view=graph-rest-1.0&amp;tabs=http
  
  $secret = &quot;xxx.5i2v&quot;
  $clientid=&quot;xx-45f3-464f-xx-xx&quot;
  $tenantid=&quot;xx-x-4f1f-xx-x&quot;
  
  
  $Body = @{
      'tenant' = $tenantid
      'client_id' = $clientid
      'scope' = 'https://graph.microsoft.com/.default'
      'client_secret' = $secret
      'grant_type' = 'client_credentials'
  }
  
  $Params = @{
      'Uri' = &quot;https://login.microsoftonline.com/$tenantid/oauth2/v2.0/token&quot;
      'Method' = 'Post'
      'Body' = $Body
      'ContentType' = 'application/x-www-form-urlencoded'
  }
  
  $AuthResponse = Invoke-RestMethod @Params
  
  $Headers = @{
      'Authorization' = &quot;Bearer $($AuthResponse.access_token)&quot;    
      'ContentType' = 'application/json'
  }
  
  # WORKS!
  $Result = Invoke-RestMethod -Uri 'https://graph.microsoft.com/v1.0/sites/xx-53D2-xx-xx-xx/permissions' -Headers $Headers
  $bodyTxt = $Result | ConvertTo-Json -Depth 100
  write-host $bodyTxt 
  
  
  $body = @{
      roles               = @(&quot;write&quot;)    
      grantedToIdentities = @( @{
              application = @{
                  displayName = &quot;Test 7&quot;                
                  id = &quot;xx-45f3-xx-aac4-xx&quot;                
              }
          })
  }
  
  $bodyTxt = $body | ConvertTo-Json -Depth 100
  
  # FAILS
  Invoke-WebRequest -Uri 'https://graph.microsoft.com/v1.0/sites/xx-53D2-xx-xx-xx/permissions' -Method POST -Body $body -Headers $Headers
  </code></pre>
  <p>It must be the way I create the post request. Any pointer to what I am doing wrong?</p>