cancel
Showing results for 
Search instead for 
Did you mean: 

REST POST measure to Sensor with capabilitySet (SCP IoT)

0 Kudos

Hi,

I want to POST a measure to a Sensor with multiple properties inside its capability. But I can't find the documentation.
I know how to POST a measure to a Sensor with multiple Capabilities:

{ 
     "capabilityAlternateId":["alID1","altID2","altID3"], 
     "sensorAlternateId":"SensorAltId", 
"measures":["value1", "value2", "value3" ] }

But I my scenario I need the following:

altID1 has multiple properties, how do I pass them in the JSON file?

Best regards,

Wout

Accepted Solutions (1)

Accepted Solutions (1)

fvviviani
Participant

Hello Wout,

You can check the possibilities for message payloads towards IoT Services right here:

https://help.sap.com/viewer/643f531cbf50462c8cc45139ba2dd051/Cloud/en-US/a07c639b331c4f3c9c80c073f99...

In the JSON you have posted here, the first issue is that you cannot have an array of "capabilityAlternateId" but you can specify one per JSON Object.

Let's make an example where "alID1" has three properties: "X", "Y" and "Z":

{
   "sensorAlternateId": "positionSensor1",
   "capabilityAlternateId": "altID1",
   "measures": [{
      "X": 0.4,
      "Y": 1,
      "Z": 0
   }]
}

This is my preferred format, as you can specify the property name as key. You can also omit that but you'd have to insert the measures into the array in the right order:

{
   "sensorAlternateId": "positionSensor1",
   "capabilityAlternateId": "altID1",
   "measures": [{
      0.4,
      1,
      0
   }]
}

If you want to insert different capabilities in the same message, you can include more JSON objects in a JSON array like this, assuming "altID2" has the same properties as "altID1":

[
   {
      "sensorAlternateId": "positionSensor1",
      "capabilityAlternateId": "altID1",
      "measures": [{
         "X": 0.4,
         "Y": 1,
         "Z": 0
       }]
   },
   {
      "sensorAlternateId": "positionSensor1",
      "capabilityAlternateId": "altID2",
      "measures": [{
         "X": 3,
         "Y": 0.5,
         "Z": 2.3
       }]
   }
]

Let me know if this answers your question,

BR,

Federico

Answers (0)