0

Here is my request.

POST https://proximitybeacon.googleapis.com/v1beta1/beaconinfo:getforobserved?key=<API_KEY>

with POST data

 {
  "observations": [
    {
      "advertisedId": {
        "type": "EDDYSTONE",
        "id": "XcM0h/AuR31AWAEXxV59Xw=="
      },
      "timestampMs": "2017-11-28T12:11:23.045123456Z"
    }
  ],
  "namespacedTypes": [
    "*"
    ]
}

I've checked the beacon dashboard to see if the beacon has any attachments to it. It has a nearby notification attachment which I want to fetch using this method.

The beaconID in hex is 5dc33487f02e477d40580117c55e7d5f.

I referred to this guide for help but it seems the request they are making is wrong considering the namespacedTypes should be an array and it is a string in the blog.

Here is the documentation for the API.

UPDATE:

If I do a Proximity API list attachment call I get the following result for the same beacon

[  
   {  
      "data":"eyJ1cmwiOiAiaHR0cHM6Ly9xLmVkZHkucHJvLzhsMkl3SiIsICJkZXNjcmlwdGlvbiI6ICJTb21lIiwgInRpdGxlIjogIlNvbWUifQ==",
      "creationTimeMs":"2017-12-01T18:15:37.418Z",
      "attachmentName":"beacons/3!5dc33487f02e477d40580117c55e7d5f/attachments/58dad403-7a99-4085-b338-5fe0b6660abd",
      "namespacedType":"com.google.nearby/en"
   }
]

Does this mean there is something wrong with the beaconinfo:getforobserved API call?

firecast
  • 988
  • 2
  • 10
  • 20
  • Have you tried using the Beacon Tool app to fetch the same information to see if that works? https://play.google.com/store/apps/details?id=com.google.android.apps.location.beacon.beacontools&hl=en If it does not work, then this suggests something wrong with the server setup. – davidgyoung Nov 29 '17 at 13:45
  • I thought that app was just used to register beacons on the proximity API which I've done through the API directly. Like I said The dashboard shows it has a nearby notification attached to it. Can you give me an example POST request where you are getting a response if you've tried it before just to see if the request I'm making is the culprit here or the API itself. Thanks – firecast Nov 29 '17 at 16:42

1 Answers1

1

My understanding is that getforobserved cannot fetch nearby notification attachments but only the attachments defined under the "Attachments" sections in Beacon Dashboard (consisting of a namespace, type and value). The documentation says that getforobserved accepts * to specify all types in all namespaces owned by the client. For nearby notification attachments the namespace is com.google.nearby which is not owned by client. This is my best understanding but I'm not 100% sure about it.

In any case, your getforobserved request looks correct to me. You can verify that the request works correctly by either:

1) Removing the "namespacedTypes" completely from the POST data. In this case the request will not return any attachments but it should return beacon info, so you should get a non-empty answer if the request is otherwise OK.

2) Add an attachment (the other type instead of nearby notification) to the beacon and see if the request returns something. The API will return empty if namespacedTypes is defined but there are no attachments.

Android devices can get nearby notifications automatically if they are enabled on the phone, so typically there should not be need to request the nearby attachments manually. If you want to maintain nearby notification attachments through the API, you can use the other methods provided in the API (such as the list method). If you want to scan for beacons and fetch attachments, I would use the normal attachments which offers more flexibility with the content.

ktkahkon
  • 86
  • 1
  • 4
  • There is another thing that needs to be done as well, marking the namespace of the attachment public using this [method](https://developers.google.com/beacons/proximity/reference/rest/v1beta1/namespaces/update). The "*" namespace still seems to return empty response, however if I use the specific namespace used to create the attachment then it works. – firecast Dec 07 '17 at 05:50