Dimmy
Dimmy

Reputation: 21

Cumulocity - Send Measurement/Alarm/Event using external ID via HTTP

I've been recently exploring Cumulocity and managed to use the external ID to send data (measurements/alarms/events) via MQTT. Its well documented and pretty straight forward. But I cant find how to send data (measurement/alarm/event) using ExternalID instead of source.

For example, here is how POST of a measurement looks like if you know ClientID of device:

 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"
}'

Is there a way to replace that "source": {"id":"1234567" }, with external ID? What would the request look like?

Upvotes: 0

Views: 301

Answers (1)

Stefan Vaillant
Stefan Vaillant

Reputation: 469

As of today, this is not possible:

Instead you have to first convert the externalID to the source id once (e.g. when the device is booted its done as first actions). Afterwards send all requests (e.g. POSTs to create measurements/alarms/events) using this retrieved sourceID.

This is also described in the Device SDK for HTTP here: https://cumulocity.com/guides/device-sdk/rest#step-1-check-if-the-device-is-already-registered .

Thanks for the good feedback on the documentation!

Upvotes: 1

Related Questions