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?
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.