Reputation: 1
I am experiencing the same problem as i am trying to create a chart using PHP Google Sheets API error 400 Invalid requests[0].addChart: error pops up but I was advised, not to reply unless it was answer to the problem.
I noticed that the $chart variable contains a null value for the sheetId, even when I don't set the sheet ID. Could this be causing the issue? Looking at the Google API code, this seems impossible to resolve.
Here is my code:
$position = new Google_Service_Sheets_EmbeddedObjectPosition();
$position->setOverlayPosition(
new Google_Service_Sheets_OverlayPosition([
'anchorCell' => [
'sheetId' => $sheets_by_name['channel view'], // this contains the correct id
'rowIndex' => 2,
'columnIndex' => 2,
],
'offsetXPixels' => 50,
'offsetYPixels' => 50,
'widthPixels' => 480,
'heightPixels' => 360,
]),
);
$chart->setPosition($position);
$chart_request = new Google_Service_Sheets_AddChartRequest($chart);
I basically did the same thing as in the related post, but with correct solution. I expected the error to go away, but it didn't.
Upvotes: 0
Views: 16