azureazure-iot-central

IoT Central REST API to query devices


Under this link Microsoft describes how to use the REST-API to query the stored data from IoT Central. It is a POST

https://{your app subdomain}.azureiotcentral.com/api/query?api-version=1.1-preview

and the body with

"query": "SELECT $id, $ts, temperature, humidity FROM urn:modelDefinition:fupmoiu28b:ymju9efv9 WHERE WITHIN_WINDOW(P1D)"

This works fine, but how do I query the data for a device model with components? I still get the Error:

{
"error": {
    "code": "NotFound",
    "message": "The requested resource was not found. You can contact support at https://aka.ms/iotcentral-support. Please include the following information. Request ID: 2383fajc, Time: Wed, 08 Dec 2021 15:32:22 GMT.",
    "requestId": "2383fajc",
    "time": "Wed, 08 Dec 2021 15:32:22 GMT"
}

}

Is this in general not possible?

Thank you init5


Solution

  • The solution was quite trivial and was already posted here by someone (thanks to the person who was able to answer the question for me). Unfortunately, I no longer see the answer here, so I am posting the solution here again so that others with this problem can find a solution here.

    "query": "SELECT your_telemtry, model.your_telemetry FROM device template ID WHERE WITHIN_WINDOW(P1D)"
    

    The "trick" here is to add the module name infront of the telemetry from the module. Hope that helps ;)