title: How to send update request body?
body: <p>I am trying to input data into a google sheet using the nodejs googleapis package. I'm using the quickstart code they give you as boilerplate, and I'm struggling to find out what the proper form is for the "request" object in the sheets.spreadsheets.values.update function.</p>
  
  <p>I would have thought this would be easy to figure out, but the documentation is unclear and contradictory.</p>
  
  <p>Here's what it says on the node.js tab on the spreadsheet.values.update page in the <a href="https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/update" rel="nofollow noreferrer">google sheets api documentation</a></p>
  
  <p>According to this page, the "request" object should look like this:</p>
  
  <pre><code>var request = {
      // The ID of the spreadsheet to update.
      spreadsheetId: 'my-spreadsheet-id',  // TODO: Update placeholder value.
  
      // The A1 notation of the values to update.
      range: 'my-range',  // TODO: Update placeholder value.
  
      // How the input data should be interpreted.
      valueInputOption: '',  // TODO: Update placeholder value.
  
      resource: {
        // TODO: Add desired properties to the request body. All existing properties
        // will be replaced.
      },
  
      auth: authClient,
    };
  </code></pre>
  
  <p>Range, spreadsheetID, and valueInputOption are all pretty straightforward. I have no issues with those. However, the "resource object" is too vague. I have no idea what this means. In the little sample request on the right hand sidebar of the page, you can edit the "request body" to give it all the values in this request, and then a <em>values</em> attribute, which is a nested array of the values you would like to update with, which works, but it doesn't show you the actual input you need to make into the node API (which makes sense, since it isn't node-specific)</p>
  
  <p>I thought about putting a "values" attribute inside the "resources" object which just had a nested array like I would expect. This does not work. all it does is return <code>TypeError: Cannot read property 'length' of undefined</code>. If you unwrap it from the "resources" object and just send values as it's own attribute, instead you get <code>Error: Invalid JSON payload received. Unknown name "values": Cannot bind query parameter. Field 'values' could not be found in request message.</code></p>
  
  <p>Additionally, that line after all this, <code>auth: authClient</code> refers to deprecated code, authentication is done now in the creation of the sheet object, which gave me a hint that changes were being made which hadn't yet been reflected in all parts of the documentation.</p>
  
  <p>I figured that maybe there would be better information on the github documentation on the googleapis package itself, which does have sample code for <em>appending</em> to a spreadsheet, in which an attribute called <code>requestBody</code> is used like this:</p>
  
  <pre><code>const res = await sheets.spreadsheets.values.append({
      spreadsheetId,
      range,
      valueInputOption: 'USER_ENTERED',
      requestBody: {
        values: [
          ['Justin', '1/1/2001', 'Website'],
          ['Node.js', '2018-03-14', 'Fun'],
        ],
      },
    });
  </code></pre>
  
  <p>This doesn't include a <code>resources</code> object like in the sample on the sheets api documentation page, and when you try to run it, it doesn't work, responding with <code>Error: Invalid JSON payload received. Unknown name "requestBody[values]": Cannot bind query parameter. Field 'requestBody[values]' could not be found in request message.</code></p>
  
  <p>At this point, I feel like something must have recently changed about the library and/or the api that has caused this documentation to be so unhelpful, and so I am turning to stack overflow to find somebody, anybody, who has done this recently and can refer me to accurate resources. Thanks.</p>