@@ -201,17 +201,14 @@ The response to this request looks like the following example:
201
201
202
202
You can use ODATA filters to filter the results returned by the list devices API.
203
203
204
- > [ !NOTE]
205
- > Currently, ODATA support is only available for ` api-version=1.2-preview `
206
-
207
204
### $top
208
205
209
206
Use the ** $top** to set the result size, the maximum returned result size is 100, the default size is 25.
210
207
211
208
Use the following request to retrieve a top 10 device from your application:
212
209
213
210
``` http
214
- GET https://{subdomain}.{baseDomain}/api/devices?api-version=1.2-preview &$top=10
211
+ GET https://{subdomain}.{baseDomain}/api/devices?api-version=2022-07-31 &$top=10
215
212
```
216
213
217
214
The response to this request looks like the following example:
@@ -239,7 +236,7 @@ The response to this request looks like the following example:
239
236
},
240
237
...
241
238
],
242
- "nextLink" : " https://custom-12qmyn6sm0x.azureiotcentral.com/api/devices?api-version=1.2-preview &%24top=1&%24skiptoken=%257B%2522token%2522%253A%2522%252BRID%253A%7EJWYqAOis7THQbBQAAAAAAg%253D%253D%2523RT%253A1%2523TRC%253A1%2523ISV%253A2%2523IEO%253A65551%2523QCF%253A4%2522%252C%2522range%2522%253A%257B%2522min%2522%253A%2522%2522%252C%2522max%2522%253A%252205C1D7F7591D44%2522%257D%257D"
239
+ "nextLink" : " https://custom-12qmyn6sm0x.azureiotcentral.com/api/devices?api-version=2022-07-31 &%24top=1&%24skiptoken=%257B%2522token%2522%253A%2522%252BRID%253A%7EJWYqAOis7THQbBQAAAAAAg%253D%253D%2523RT%253A1%2523TRC%253A1%2523ISV%253A2%2523IEO%253A65551%2523QCF%253A4%2522%252C%2522range%2522%253A%257B%2522min%2522%253A%2522%2522%252C%2522max%2522%253A%252205C1D7F7591D44%2522%257D%257D"
243
240
}
244
241
```
245
242
@@ -254,10 +251,10 @@ Use **$filter** to create expressions that filter the list of devices. The follo
254
251
| -------------------- | ------ | --------------------------------------- |
255
252
| Equals | eq | id eq 'device1' and scopes eq 'redmond' |
256
253
| Not Equals | ne | Enabled ne true |
257
- | Less than or equals | le | indexof (displayName, 'device1') le -1 |
258
- | Less than | lt | indexof (displayName, 'device1') lt 0 |
259
- | Greater than or equals | ge | indexof (displayName, 'device1') ge 0 |
260
- | Greater than | gt | indexof (displayName, 'device1') gt 0 |
254
+ | Less than or equals | le | contains (displayName, 'device1') le -1 |
255
+ | Less than | lt | contains (displayName, 'device1') lt 0 |
256
+ | Greater than or equals | ge | contains (displayName, 'device1') ge 0 |
257
+ | Greater than | gt | contains (displayName, 'device1') gt 0 |
261
258
262
259
The following table shows the logic operators you can use in * $filter* expressions:
263
260
@@ -280,16 +277,16 @@ Currently, *$filter* works with the following device fields:
280
277
281
278
** $filter supported functions:**
282
279
283
- Currently, the only supported filter function for device lists is the ` indexof ` function:
280
+ Currently, the only supported filter function for device lists is the ` contains ` function:
284
281
285
282
```
286
- $filter=indexof (displayName, 'device1') ge 0
283
+ $filter=contains (displayName, 'device1') ge 0
287
284
```
288
285
289
- The following example shows how to retrieve all the devices where the display name has index the string ` thermostat ` :
286
+ The following example shows how to retrieve all the devices where the display name contains the string ` thermostat ` :
290
287
291
288
``` http
292
- GET https://{subdomain}.{baseDomain}/api/deviceTemplates?api-version=1.2-preview &$filter=index (displayName, 'thermostat')
289
+ GET https://{subdomain}.{baseDomain}/api/deviceTemplates?api-version=2022-07-31 &$filter=contains (displayName, 'thermostat')
293
290
```
294
291
295
292
The response to this request looks like the following example:
@@ -331,7 +328,7 @@ $orderby=displayName desc
331
328
The following example shows how to retrieve all the device templates where the result is sorted by ` displayName ` :
332
329
333
330
``` http
334
- GET https://{subdomain}.{baseDomain}/api/devices?api-version=1.2-preview &$orderby=displayName
331
+ GET https://{subdomain}.{baseDomain}/api/devices?api-version=2022-07-31 &$orderby=displayName
335
332
```
336
333
337
334
The response to this request looks like the following example:
@@ -366,7 +363,7 @@ You can also combine two or more filters.
366
363
The following example shows how to retrieve the top 2 device where the display name contains the string ` thermostat ` .
367
364
368
365
``` http
369
- GET https://{subdomain}.{baseDomain}/api/deviceTemplates?api-version=1.2-preview &$filter=contains(displayName, 'thermostat')&$top=2
366
+ GET https://{subdomain}.{baseDomain}/api/deviceTemplates?api-version=2022-07-31 &$filter=contains(displayName, 'thermostat')&$top=2
370
367
```
371
368
372
369
The response to this request looks like the following example:
0 commit comments