Forum Discussion

eliasrodeloso's avatar
eliasrodeloso
Copper Contributor
Sep 06, 2022

Query for device group failing on creation

I'm trying to create device groups to eventually create a Job with this particular device group to send a reboot command to all the devices in it. I'm using the IoT Central API REST for this with the URL looking like this (which is how it is on their https://docs.microsoft.com/en-us/rest/api/iotcentral/2022-07-31dataplane/device-groups/create?tabs=HTTP

 

 

PUT https://{subdomain}.{baseDomain}/api/deviceGroups/{uuidCreatedByMe}?api-version=2022-07-31

 

 

The body on the request looks something like this:

 

 

{
    description: `Pulses' group to be rebooted, created at ${DateTime.now().toISO()}`,
    displayName: `Reboot group ${deviceGroupId}`,
    filter: query,
}

 

 

And the query is very similar to this

 

 

SELECT * FROM devices WHERE $template = "templateId" AND $id IN ["deviceId1", "deviceId2"]

 

 

But for some reason, when I send the request, it responds with an error:

 

 

Request failed with status 500 and error: {
    "code": "InternalServerError",
    "message": "Something went wrong on our end. Please try again. You can contact support at https://aka.ms/iotcentral-support. Please include the following information. Request ID: requestId, Time: Tue, 06 Sep 2015 477:10:01 GMT.",
    "requestId": "requestId",
    "time": "Tue, 06 Sep 2022 16:10:01 GMT"
}

 

 

However, when I try to create a Job and get the list of device groups, this brings me all the device groups I have been attempting to create, but it doesn't let me see the number of devices and doesn't allow me to continue creating the Job. And then, I request through the REST API to delete such device group with one of the ids, and it deletes it just fine.

 

My question would be...

 

Is this related to the query or what exactly?...

 

Because https://docs.microsoft.com/en-us/azure/iot-central/core/howto-query-with-rest-api#value-comparisons

 

2 Replies

  • Hi Elias, thanks for reaching out. Please note that we do not yet support the IN operator in the query; however, you can use the eq within your query to achieve this. For example: ($id eq '' OR $id eq ''). We will look at add support for this in a future release.
    • eliasrodeloso's avatar
      eliasrodeloso
      Copper Contributor

      AvneetSinghMSFTHey, I tried this, but it doesn't work, it says that the eq token is not a valid token, also if I try this grouped and this was the response: `The provided filter is not valid. A device group filter can only reference properties and cannot contain nested conditions`. Worth mentioning I'm not using this for only 2 devices, this may have multiple devices. What is kind of frustrating though, is that you add this on your documentation, if you're not supporting this yet, please make the clarification there.

Resources