title: Write to Sheet with Google Sheets API
body: <p>I want write data to my sheet:</p>
  
  <pre><code>$spreadsheetId = 'xxx';
  $range = 'Test!A1:D5';
  
  $values = [
    'range' =&gt; "A1",
    'majorDimension' =&gt; 'DIMENSION_UNSPECIFIED',
    'values' =&gt; [
      ["Item", "Cost", "Stocked", "Ship Date"],
      ["Wheel", "$20.50", "4", "3/1/2016"],
      ["Door", "$15", "2", "3/15/2016"],
      ["Engine", "$100", "1", "30/20/2016"],
    ],
  ];
  
  $body = new Google_Service_Sheets_ValueRange(array(
    'values' =&gt; $values
  ));
  $params = array(
    'valueInputOption' =&gt; 'RAW'
  );
  $result = $service-&gt;spreadsheets_values-&gt;update($spreadsheetId, $range, $body, $params);
  </code></pre>
  
  <p>But in log i see:</p>
  
  <pre><code>PHP Fatal error:  Uncaught exception 'Google_Service_Exception' with message '{
    "error": {
      "code": 400,
      "message": "Invalid JSON payload received. Unknown name \"range\" at 'data.values': Cannot find field.\nInvalid JSON payload received. Unknown name \"major_dimension\" at 'data.values': Cannot find field.",
      "errors": [
        {
          "message": "Invalid JSON payload received. Unknown name \"range\" at 'data.values': Cannot find field.\nInvalid JSON payload received. Unknown name \"major_dimension\" at 'data.values': Cannot find field.",
          "domain": "global",
          "reason": "badRequest"
        }
      ],
      "status": "INVALID_ARGUMENT"
    }
  }
  </code></pre>
  
  <p>What am I doing wrong? I will be grateful for the example code that works for you :)</p>
  
  <p>In the examples there is not enough information( <a href="https://developers.google.com/sheets/api/guides/values#writing_to_a_single_range" rel="nofollow noreferrer">https://developers.google.com/sheets/api/guides/values#writing_to_a_single_range</a>)</p>