I have tried below code to create new sheet inside spreadsheet, but it’s not working.
$service = new Google_Service_Sheets($client);
//pr($service);
$spreadsheetId = ‘You spredsheet id’;
$json_request_string = ‘{“requests”:[{“addSheet”: {“properties”: {“title”: “Project tasks”}}}]}’;
//$requests = json_decode($json_request_string);
// TODO: Assign values to desired properties of `requestBody`:
$requestBody = new Google_Service_Sheets_BatchUpdateSpreadsheetRequest();
$requestBody->setRequests($json_request_string);
$response = $service->spreadsheets->batchUpdate($spreadsheetId, $requestBody);
I get this error:
Request had invalid authentication credentials error