累积性-通过HTTP使用外部ID发送测量/警报/事件

时间:2019-03-06 23:54:15

标签: iot cumulocity

我最近一直在探索Cumulocity,并设法使用外部ID通过MQTT发送数据(度量/警报/事件)。它有据可查,非常简单。 但是我找不到如何使用ExternalID而不是源发送数据(度量/警报/事件)的方法。

例如,如果您知道设备的ClientID,以下是测量的POST外观:

 curl -X POST \
  https://myTenant.cumulocity.com/measurement/measurements \
  -H 'Accept: application/vnd.com.nsn.cumulocity.measurement+json' \
  -H 'Authorization: Basic mytoken' \
  -H 'Content-Type: application/json' \
  -d '{
    "c8y_TemperatureMeasurement": {
        "T": { 
            "value": 25,
            "unit": "C" }
        },
    "time":"2019-03-07T10:03:14.000+11:00", 
    "source": {
        "id":"1234567" }, 
    "type": "c8y_TemperatureMeasurement"
}'

是否可以用外部ID替换该“源”:{“ id”:“ 1234567”}? 该请求是什么样的?

1 个答案:

答案 0 :(得分:1)

到目前为止,这是不可能的:

相反,您必须首先将externalID转换为源ID(例如,在启动设备时,将其作为第一操作完成)。然后使用此检索到的sourceID发送所有请求(例如POST以创建测量/警报/事件)。

在Device SDK for HTTP中也对此进行了描述:https://cumulocity.com/guides/device-sdk/rest#step-1-check-if-the-device-is-already-registered

感谢您对文档的反馈!