2

I am trying to list the number of beacons registered with my OAuth key, but am only receiving 10 at a time. I am structuring my HTTP request like so:

https://proximitybeacon.googleapis.com/v1beta1/beacons

I have tried to set maxResults to be greater than the total number of beacons retrieved (?maxResults=20), but that always returns a 400 Bad Request error (maxResults is not known). When I try to use pageToken=[KNOWN NEXT PAGE TOKEN], I get a 500 internal error.

Without the ability to use either of these, I can't see past my first 10 beacons. Any help would be greatly appreciated!

EDIT: According to this document, it looks like these parameters are not available for the Proximity API. I'm not sure if that's correct, because that would mean that it's not possible to list any more than the first 10 returned beacons.

avgrammer
  • 409
  • 5
  • 13

3 Answers3

2

The correct way to get a subsequent page of results is to use the pageToken parameter as you describe. While I believe I have seen this work before, I have verified that the API is currently returning a 500 error for this. (See my test results below.) It appears that this is a server-side problem.

curl 'https://proximitybeacon.googleapis.com/v1beta1/beacons?pageSize=3' -H 'Authorization: Bearer MY_SECRET_OAUTH_TOKEN_HERE'
{
  "beacons": [
    {
      ...
    },
    {
      ...
    },
    {
      ...
    }
  ],
  "nextPageToken": "Civ55nT/+//+zN7Pzs/Nz8zPy8/Kz8nPyM/Hz8bPns+dz5zPm8+ayMmdnf/+EAMhko+M85V85JMx00LwZ+bdJe8xuNeGz7eSTJAxP86ZtGulO0o5AQAEAIsZAABQAFoLCcck85hsjQ0JEAE",
  "totalCount": "5"
}

$ curl 'https://proximitybeacon.googleapis.com/v1beta1/beacons?pageSize=3&pageToken=Civ55nT/+//+zN7Pzs/Nz8zPy8/Kz8nPyM/Hz8bPns+dz5zPm8+ayMmdnf/+EAMhko+M85V85JMx00LwZ+bdJe8xuNeGz7eSTJAxP86ZtGulO0o5AQAEAIsZAABQAFoLCcck85hsjQ0JEAE' -H 'Authorization: Bearer MY_SECRET_OAUTH_TOKEN_HERE'
{
  "error": {
    "code": 500,
    "message": "Internal error encountered.",
    "status": "INTERNAL"
  }
}

```

davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • Thanks David. Given the relative infrequency of people using this API, I presume this won't be a priority to the team, but I'll see if I can find where to submit a ticket to Google. – avgrammer Feb 05 '16 at 23:44
  • In the meantime, I tried using the "pageSize" parameter to see if I could increase my number of returned results to be equal to the total possible results. This worked as a workaround for me, instead of maxResults. – avgrammer Feb 05 '16 at 23:47
  • I tried with `pageSize=10000` as my number of recorded beacon in proximity platform is around that number but I only received first 1000 items. But fun does not end here, if I try to call again the API with `pageToken` parameter, I get a 400 error. – Nicocube May 10 '16 at 16:01
2

After wasting hours on this problem (other problem with sending post request with empty request body to activate/deactivate beacons...), my team chose to use the fabulous Google Proximity Beacon API Client which solve all this problems and give you a well much better experience, models and fonctionnalities.

Note that listing can still have some problems with large listing and small beacons by page : 20 000 beacons , 100/page, 1000 simulation ==> ~80% done

Vladk-el
  • 21
  • 4
1

When developping a custom client I experienced the same 500 error because the pageToken provided in the json is not url-safe: You need to url encode the token before providing it as a url parameter.

Then paging worked unreliably: random 400 errors after few small pages (pageSize 10-100) or the second big page (pageSize 1000).

Now using the official java client with same Oauth2 Credential I can reliably iterate through 20,000+ beacons (with pageSize 1000) so i probably missed something with parameters encoding and the API do work.

lampe
  • 46
  • 3