【问题标题】:IBM Watson IoT Platform - How to get last event / state of a deviceIBM Watson IoT Platform - 如何获取设备的最后事件/状态
【发布时间】:2020-12-02 15:35:00
【问题描述】:

我在 Watson IoT Platform 在线仪表板上创建了一个设备。 此设备使用基本身份验证和 use-token-auth 及其密码发布数据:

URL: https://noz238.messaging.internetofthings.ibmcloud.com:8883/api/v0002/device/types/Light/devices/TestLight/events/status
Method: POST    
Body: {"isOn":false}

此发送正文在 https://noz238.internetofthings.ibmcloud.com/dashboard/devices/browse 的最新事件视图中可见

我无法使用此 REST API(以及用于可视化的 API 密钥)获取此设备的最新状态/事件。我在尝试不同的 api 时确实得到了意想不到的响应

我试过这个端点:https://noz238.internetofthings.ibmcloud.com/api/v0002/device/types/Light/devices/TestLight/events (https://docs.internetofthings.ibmcloud.com/apis/swagger/v0002/info-mgmt.html#/Last%20Event%20Cache/get_device_types__deviceType__devices__deviceId__events)

回答: 钢筋混凝土:403

{
    "message": "CUDCS0106E: <missing messageId in bundle com.ibm.wiotp.util.httpservice.nls.servicemessages>",
    "exception": {
        "id": "CUDCS0106E",
        "properties": [
            "noz238"
        ]
    }
}

我尝试了这个端点:https://noz238.internetofthings.ibmcloud.com/api/v0002/device/types/Light/devices/TestLight/state/test (https://docs.internetofthings.ibmcloud.com/apis/swagger/v0002/state-mgmt.html#/Devices/get_device_types__typeId__devices__deviceId__state__logicalInterfaceId_)

回答: 遥控:404

{
    "message": "CUDIM0001E: No 'Device Type' with id 'Light' could be found in org 'noz238'",
    "exception": {
        "id": "CUDIM0001E",
        "properties": [
            "noz238",
            "Light",
            "Device Type"
        ]
    }
}

如何获取设备的最新事件/状态?

【问题讨论】:

标签: ibm-cloud iot ibm-watson watson-iot


【解决方案1】:

我不确定您是否已经发现,但在右上方的仪表板中有一个问号,您可以使用 swagger 访问所有 API,swagger 将使您更好地了解端点是什么您需要使用的。

设备类型是一回事,设备 ID 是另一回事,可能您没有得到正确的设备 ID。

此命令将为您提供您拥有的所有设备。

卷曲 -X GET “https://noz238.internetofthings.ibmcloud.com/api/v0002/bulk/devices?_limit=25” -H "接受:应用程序/json"

此命令将为您提供该设备的所有日志

卷曲 -X GET “https://noz238.internetofthings.ibmcloud.com/api/v0002/device/types/{DEVICE_TYPE}/devices/{DEVICE_ID}/diag/logs” -H "接受:应用程序/json"

您可以在此处访问 swagger 文档中提供的所有端点

https://noz238.internetofthings.ibmcloud.com/docs/index.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-06-21
    • 2016-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多