I am trying to upload data to google sheets via sheets API, but I cannot figure out right format of data. This is how I understood It from docs,
public function insert($spreadSheetId)
{
$body = array(
array('ab', 'cd'),
array('ef', 'gh')
);
$values = new Google_Service_Sheets_ValueRange();
$values->setValues(['values' => $body]);
$this->client->spreadsheets_values->update($spreadSheetId, 'A1:B2', $values, ['valueInputOption' => 'RAW']);
}
But I am getting expcetion
HP Fatal error: Uncaught exception 'Google_Service_Exception' with message '{
"error": {
"code": 400,
"message": "Invalid values[0][0]: list_value {\n values {\n string_value: \"ab\"\n }\n values {\n string_value: \"cd\"\n }\n}\n",
"errors": [
{
"message": "Invalid values[0][0]: list_value {\n values {\n string_value: \"ab\"\n }\n values {\n string_value: \"cd\"\n }\n}\n",
"domain": "global",
"reason": "badRequest"
}
],
"status": "INVALID_ARGUMENT"
}
}
Right format was