2

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:

  • Call the API endpoint with or without the API key and the other parameters, as follows:

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!


Edit 2:

  • Also stopped the script's time-based triggers 2 days ago, still no luck!
halfer
  • 19,824
  • 17
  • 99
  • 186
user7607751
  • 465
  • 7
  • 27
  • have you uploaded photos via this API already? if not, an empty JSON with 200 response would be normal. – Erich Aug 23 '19 at 12:47
  • @Erich, I'm not trying to upload photo, I'm using the API endpoint `GET https://streetviewpublish.googleapis.com/v1/photos?fields=nextPageToken%2Cphotos&key={YOUR_API_KEY}` to get the list of the photos I uploaded before. At the APIs explorer it's `streetviewpublish.photos.list`. And yes, I have photos on the account now already. – user7607751 Aug 23 '19 at 13:00
  • Your code? Per user quota is 60. Haven't you used it up? – TheMaster Aug 23 '19 at 13:09
  • 1
    what happens when you remove `nextPageToken%2C` from the request? – Erich Aug 23 '19 at 13:10
  • @TheMaster I updated the question to include the code I use at the script to contact the API, please note I was running a time-based trigger every 15 minutes. – user7607751 Aug 23 '19 at 13:14
  • @Erich When I remove the parameters from the request at the Google APIs Explorer now I get response code `200` with empty JSON object. – user7607751 Aug 23 '19 at 13:17
  • It look like there is no photos Id parameters. Based on documentation it must be photoIds=&photoIds= in the url – St3ph Aug 23 '19 at 13:21
  • @St3ph This is the documentation for the method I'm trying to use `photos.list`: https://developers.google.com/streetview/publish/reference/rest/v1/photos/list , I think the parameter you refer to is `filter`, and I understand it's an optional parameter, I don't see anything saying it's a **requirement** or a **must** be included parameter. – user7607751 Aug 23 '19 at 13:42
  • @TheMaster the 60 quote is PER MINUTE! I don't think I used it up! I just run the the script once every 15 minutes. – user7607751 Aug 23 '19 at 13:46
  • Do you have a next page token? Could you try 1.`var url = 'https://streetviewpublish.googleapis.com/v1/photos?key=' + API_KEY;` and 2. without a api key: `var url = 'https://streetviewpublish.googleapis.com/v1/photos'` – TheMaster Aug 23 '19 at 14:58
  • This endpoint is for photos you published. Are you using an account that publish photos? Just to be sure. – St3ph Aug 24 '19 at 12:42
  • @TheMaster I tried both suggestions you suggested, but, unfortunately, still the same response! – user7607751 Aug 26 '19 at 12:31
  • @St3ph Yes, the account has 360 photos at it, and the API was responding with JSON object before with the photo urls, view counts and everything! – user7607751 Aug 26 '19 at 12:31
  • `and it has been working just fine for couple of hours` If you can't access the photos even with api explorer, you might want to contact Google support or open a new issue at bugtracker – TheMaster Aug 26 '19 at 16:27
  • Did you ever find a solution to this issue? I've just started using this API and I'm running into the same problem. I'm trying to get the list of photos from a user that I know has published photos, yet all I'm getting is a 200 response and an empty JSON object. – timtom Nov 28 '21 at 03:04

1 Answers1

3

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.

Seth T.
  • 31
  • 2