beaconinfo.getforobserved总是返回一个空的响应 [英] beaconinfo.getforobserved always returning an empty response

查看:184
本文介绍了beaconinfo.getforobserved总是返回一个空的响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的请求。

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

带有POST数据

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

I已检查信标仪表板以查看信标是否有任何附件。它有一个附近的通知附件,我想用这个方法获取。



十六进制的beaconID是 5dc33487f02e477d40580117c55e7d5f



我提到这个指南

a>寻求帮助,但似乎他们的要求是错误的,因为namespacedTypes应该是一个数组,并且它是一个博客中的字符串。



这里是 API文档



更新:



如果我使用Proximity API list 附件调用我对同一个信标获得以下结果

  [
{
数据: eyJ1cmwiOiAiaHR0cHM6Ly9xLmVkZHkucHJvLzhsMkl3SiIsICJkZXNjcmlwdGlvbiI6ICJTb21lIiwgInRpdGxlIjogIlNvbWUifQ ==,
creationTimeMs: 2017-12-01T18:15:37.418Z,
ATTACHMENTNAME:信标/ 3 5dc33487f02e477d40580117c55e7d5f /附件/ 58dad403-
namespacedType:com.google.nearby / en
}
]

pre>

这是否意味着 beaconinfo:getforobserved API调用有问题?

$ b $我的理解是,getforobserved不能获取附近的通知附件,而只能获取Beacon仪表板中附件部分定义的附件(包括命名空间,类型和属性值)。该文档说getforobserved接受*来指定客户端拥有的所有名称空间中的所有类型。对于附近的通知附件,名称空间是com.google.nearby,它不属于客户端。这是我最好的理解,但我不完全确定它。



无论如何,您的getforobserved请求看起来是正确的。您可以通过以下方式验证请求是否正常工作:



1)从POST数据中完全删除namespacedTypes。在这种情况下,请求不会返回任何附件,但它会返回信标信息,所以如果请求没有问题,您应该得到一个非空的答案。



2)向信标添加附件(另一种类型,而不是附近的通知)并查看请求是否返回。如果命名空间类型被定义,但没有附件,则API将返回空。



如果手机上启用了Android设备,则自动获取附近通知,所以通常不应该需要手动请求附近的附件。如果您想通过API维护附近的通知附件,则可以使用API​​中提供的其他方法(如列表方法)。如果你想扫描信标并获取附件,我会使用正常的附件,它为内容提供了更多的灵活性。


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.

这篇关于beaconinfo.getforobserved总是返回一个空的响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆