title: Invoke-WebRequest failed - "Problems parsing json" with GitHub api
body: <p>I am attempting to communicate with the <code>Graphql</code> api through powershell. According to Github, one must first do the following <code>curl</code> call.</p>
  
  <pre><code>curl -H "Authorization: bearer token" -X POST -d " \
   { \
     \"query\": \"query { viewer { login }}\" \
   } \
  " https://api.github.com/graphql
  </code></pre>
  
  <p>Using <strong>GitHub Enterprise</strong>, on powershell I do the following calls:</p>
  
  <pre><code>$url = "http://github.company.com/api/graphql" # note that it's http, not https
  
  $body = "`"query`":`"query { viewer { login }}`""                                               #`
  
  $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
  
  $headers.Add("content-type","application/json")
  
  $headers.Add("Authorization","bearer myTokenNumber")
  
  $response = Invoke-WebRequest -Uri $url -Method POST -Body $body -Headers $headers
  </code></pre>
  
  <p>I keep getting the same error message, that there are problems parsing JSON.</p>
  
  <p>I assume the error is with the <code>body</code> tag, but I can't see how. </p>
  
  <p><code>echo $body</code> gives <code>"query":"query { viewer { login }}"</code></p>
  
  <p>What is the issue here?</p>
  
  <p>Exact error message:</p>
  
  <pre><code>Invoke-WebRequest : {"message":"Problems parsing JSON","documentation_url":"https://developer.github.com/v3"}
  At line:1 char:13
  + $response = Invoke-WebRequest -Uri $url -Method POST -Body $body -Headers $heade ...
  +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
     eption
      + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
  </code></pre>