Reputation: 505
I'm trying to make an HTTP GET request to the Google Street View Publish API, inside a Google Apps Script script, to fetch the photos list and save metadata about them to a Google spreadsheet.
The code I'm using on the script to contact the API:
var url = 'https://streetviewpublish.googleapis.com/v1/photos?fields=nextPageToken%2Cphotos&key=' + API_KEY;
var response = UrlFetchApp.fetch(url, {
muteHttpExceptions: true,
headers: {
//the accessToken is borrowed from the Apps Script Infrastructure `ScriptApp.getOAuthToken()`
//source: https://www.youtube.com/watch?v=aP6pxK3jexc
Authorization: 'Bearer ' + ScriptApp.getOAuthToken()
}
});
console.log('API response:\n' + response);
And including the Street View Auth at the script's manifest oauthscopes.json
file:
...
"oauthScopes": [
"https://www.googleapis.com/auth/streetviewpublish",
"https://www.googleapis.com/auth/script.external_request",
"https://www.googleapis.com/auth/spreadsheets"
]
...
Been using a time-based trigger to run the script every 15 min, and it has been working just fine for couple of hours and returning a JSON object with the photos on the account, until the API stopped to return a response, and it's now just returning an empty JSON object {}
.
I don't think I consumed the quote for the API usage, my numbers from the GCP dashboard as follows:
Tried to create another API KEY
and use it at the script, but still no luck.
Also, when tried to test the API from the Google APIs Explorer, authorize and execute, it gives me the response code 200
with an empty JSON object as well.
This has been working before, but, now it doesn't!
What might be the problem here?
As suggested at the comments, I tried to:
https://streetviewpublish.googleapis.com/v1/photos?fields=nextPageToken%2Cphotos&key=' + API_KEY
https://streetviewpublish.googleapis.com/v1/photos?key=' + API_KEY
https://streetviewpublish.googleapis.com/v1/photos
Also, tried to revoke the access for both the Google APIs Explorer and the script on Google Apps Script, from the account security checkup. Which because of it when tried to run it again, it opened a popup window to ask for the authorization/permission again, which I granted as well.
Tried to log out of the Google account & clearing the browser's cache.
Yet, still, the same empty JSON object response!
Upvotes: 2
Views: 2919
Reputation: 31
The documentation says that pageSize
defaults to 100. This is not the case. If you specify the pageSize
parameter, it returns a response with photos.
Upvotes: 3