Product/components used and version/fix level:
Detailed explanation of the problem:
Hi, I have measurements in this way.
Now I want to fetch the latest value for all the fragments of type A. I tried
this API but it is fetching only abc fragment values but not xyz values. I also tried custom query but that is also not working. Can we use custom query on measurements? If yes could you please tell me how can i carry out my use case with this? OR could you please tell me how can i achieve this use case with any other way.
if you want to query multiple measurement series in one call, also take a look at the retrieve a list of series and their values measurement endpoint.
It accepts a comma separated list of series-names:
The series endpoint won’t give me the latest value, it will only fetch the values between a time period. even if i just set dateTo as current time i have to query the series to find a value if its not present for some time like for example if the value i am searching for was entered 2 months ago, then i have to search the series endpoint till that time. I could do the same thing with measurement endpoint as well, but i dont want it to be like that. I want to fetch directly the latest values itself.
Is it possible to use custom query in measurements?
Also, could you suggest any other way?
If you only want to retrieve the latest measurement you will need to perform one request per combination of fragment/series.
You can use a pageSize of 1 in this case as you are only interested in the latest value.
So in your case e.g. one request to:
and another one to:
There is no endpoint to retrieve the latest value of different measurement series in a single request as of now.
Okay thanks for the confirmation. Could you please also tell me if it’s possible to use custom query on measurements like we do in inventory. like query = $filter= $order by creationtime desc something like that
The API is documented here: Cumulocity IoT - OpenAPI Specification and as you can see, this is not supported.
Thanks for the confirmation