first let me say i apologize if this is an easy solution, i've never used google api or anything similar, as well as i'm new to php
i'm currently trying to read a spreadsheet using google sheets api and just print it out. i think everything looks fine, but when i run it, it gives me this error:
PHP Fatal error: Uncaught Google\Service\Exception: {
"error": { "code": 404, "message": "Requested entity was not found.", "errors": [ { "message": "Requested entity was not found.", "domain": "global", "reason": "notFound" } ], "status": "NOT_FOUND" } }
here is my php file:
require __DIR__ . '/vendor/autoload.php';
$client = new \Google_Client();
$client->setApplicationName('Sheets Test');
$client->setScopes([\Google_Service_Sheets::SPREADSHEETS]);
$client->setAccessType('offline');
$client->setAuthConfig(__DIR__ . '/credentials.json');
$service = new \Google_Service_Sheets($client);
$spreadsheetId = "1sefMmSCVnQRMVFuG8l5SKx7phpD2vvmwzq7opsgyuebYIU";
$range = "currentRatings!A2:C4";
$response = $service->spreadsheets_values->get($spreadsheetId, $range);
$values = $response->getValues();
if(empty($values)){
print "No data found. \n";
} else {
$mask = "%10s %-10s $s\n";
foreach($values as $row){
echo sprintf($mask, $row[2], $row[1], $row[0]);
}
}
as shown above, i did connect a credentials file which is the same service account that the sheet is shared to. i also know that the problem occurs/starts at this line:
$response = $service->spreadsheets_values->get($spreadsheetId, $range);
here's what i've tried:
okay so i found out that my id was too long, i was probably accidentally typing in it at some point which caused the error. i did check the id, but i only checked the front and back of the id.