How to post multiple measurement in 1 go?

Product/components used and version/fix level are you on:

Cumulocity Free Trial

Detailed explanation of the problem:

Hi, I just want to know if there is any way to post multiple measurements in 1 go in the cumulocity APIs. Like for example, it could be something like:

[
    {
        "source": {
            "id": "1"
        },
        "time": "2023-05-09T09:30:30.500Z",
        "type": "ABC",
        "ABC": {
            "A": {
                "unit": "",
                "value": 0.7
            }
    },
    {
        "source": {
            "id": "2"
        },
        "time": "2023-05-09T09:30:30.500Z",
        "type": "ABC",
        "B": {
            "B": {
                "unit": "",
                "value": 0.7
            }
    }
]

Something like this, could be the structure.
Regards,
Samanyu

Yes, that’s possible. You can put your measurements in an array and send it to the measurements endpoint. See section Create multiple measurements here: Cumulocity IoT - OpenAPI Specification

In your example you would send below JSON to /measurement/measurements endpoint. Note that the Content-Type header needs to be set to application/vnd.com.nsn.cumulocity.measurementcollection+json in order to use it.

{
   "measurements":[
      {
         "source":{
            "id":"1"
         },
         "time":"2023-05-09T09:30:30.500Z",
         "type":"ABC",
         "ABC":{
            "A":{
               "unit":"",
               "value":0.7
            }
         }
      },
      {
         "source":{
            "id":"2"
         },
         "time":"2023-05-09T09:30:30.500Z",
         "type":"ABC",
         "B":{
            "B":{
               "unit":"",
               "value":0.7
            }
         }
      }
   ]
}

By the way, unit is not a mandatory field, you could also leave it out instead of passing an empty string.

2 Likes

https://cumulocity.com/api/core/10.15.0/#operation/postMeasurementCollectionResource

2 Likes

Thanks Tim and Korbinian :slight_smile:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.