title: Google Sheets API Python - Clear sheet
body: <p>I'd like to constantly update/re-write to a Google sheet. I cannot just update it, though, without clearing out the old sheet because sometime the update has less rows then the previous and the old rows are left in the sheet.</p>
  
  <p>The protocol listed on the <a href="https://developers.google.com/sheets/api/samples/sheet" rel="noreferrer">developer page</a> is thus:</p>
  
  <pre><code>{
    "requests": [
      {
        "updateCells": {
          "range": {
            "sheetId": sheetId
          },
          "fields": "userEnteredValue"
        }
      }
    ]
  }
  </code></pre>
  
  <p>Translated to python would look like this, I think:</p>
  
  <pre><code>requests = [{ 'updateCells': { 'range': { 'sheetId': spreadsheet_id }, 'fields': 'userEnteredValue' } }]
  
  body = { 'requests': requests }
  spreadsheet_id='[uniqueIDhere]'
  
  result = service.spreadsheets( ).values( ).batchUpdate(spreadsheetId=spreadsheet_id, body=body ).execute( )
  </code></pre>
  
  <p>Which returns the error:</p>
  
  <p>googleapiclient.errors.HttpError: https://sheets.googleapis.com/v4/spreadsheets/[uniqueIDhere]/values:batchUpdate?alt=json returned "Invalid JSON payload received. Unknown name "requests": Cannot find field."></p>
  
  <p>Seems weird that 'requests' is invalid as it's listed right there in the protocol. Anyways, anybody else get this to work? Thanks. - jason</p>