user7607751
user7607751

Reputation: 505

Google API returns a response 200 empty JSON

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:

Quote Numbers 1

Quote Numbers 2

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?


Edit:

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

Yet, still, the same empty JSON object response!


Edit 2:

Upvotes: 2

Views: 2919

Answers (1)

Seth T.
Seth T.

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

Related Questions