azure-iot-hubazure-iot-central

How can I send telemetry data via HTTP/REST to a second component in IoT Central?


I would like to send data from a device via CURL to an IoT Central for a use case. This works without any problems according to the following scheme:

curl -s -H "authorization: ${AUTH}" --request POST --data "$MESSAGE0" "https://$SCOPE/devices/$DEVICE_ID/messages/events?api-version=2020-03-13"

For the request I used:

$AUTH = SharedAccessSignature sr=xxxxxxx.azure-devices.net%2fdevices%2fmyDeviceName4&sig=yyyyyyyy&se=zzzzzzzzzz
$MESSAGE0 = '{"FillingLevel": 30.0, Geo_Data:{"lon":8.2393, "lat":52.02413,"alt":0}}'
$SCOPE = Scope Id from IoT Central
$DEVICE_ID = myDeviceName

I would now like to use a device model that uses more than one component and I am trying to send telemetry data to the component here as well. similar to what is described here for example: How do I send telemetry data via mqtt to a second component in IoT Central?

My call looks like this:

curl -s -H "authorisation: ${AUTH}" --request POST --data "$MESSAGE0" "https://$SCOPE/devices/$DEVICE_ID/modules/$MODULE_ID/messages/events?api-version=2020-03-13"

with

$MODULE_ID = id of the component
(all other data are the same from first call)

The data is transmitted and no error is given, but unfortunately not assigned to the component. Instead, I get the data displayed as "unmodeleddata".

My question: what should the call look like so that the data can be assigned accordingly?

Many thanks for your help


Solution

  • in the case of using the REST for sending a component telemetry data, the name of the component must be sent in the header, see the following example:

    dt-subject: thermostat1