title: Unable to write to Google Sheets ((400) Bad Request)
body: <p>I'm attempting to write to a private Google Sheets document using the API and PowerShell web requests. I know I have handled the authentication correctly as I can read from a sheet just fine using the following code:</p>
  
  <pre><code>$read = Invoke-WebRequest -Uri "https://sheets.googleapis.com/v4/spreadsheets/$sheet/values/Sheet1!A1:B2?access_token=$($token.access_token)"
  </code></pre>
  
  <p>The issue arises when I attempt to write to that same sheet (after clearing all content from the cells):</p>
  
  <pre><code>$json = @”
  {
    "range": "Sheet1!A1:D2",
    "majorDimension": "ROWS",
    "values": [
      ["Door", "15", "2", "3/15/2016"],
      ["Engine", "100", "1", "3/20/2016"]
    ]
  }
  “@
  
  Invoke-WebRequest -Uri "https://sheets.googleapis.com/v4/spreadsheets/$sheet/values/Sheet1!A1:D2:append?valueInputOption=USER_ENTERED&amp;access_token=$($token.access_token)" -Method Post -Body $json
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>Invoke-WebRequest : The remote server returned an error: (400) Bad Request.
  </code></pre>
  
  <p>What am I doing wrong?</p>