Hi guys,
I have an HTTP API call returning devices. I would like a way to count how many of the devices are servers, desktops and laptops. From the API call there are 104 devices
{
"pageDetails": {
"count": 104,
"prevPageUrl": null,
"nextPageUrl": null
},
"devices": [
{
"id": 281423,
"uid": "ccbeb8c4-4e87-0a7a-91e9-c98f8de7b155",
"siteId": 48083,
"siteName": "",
"deviceType": {
"category": "Server",
"type": "Main System Chassis"
},
},
{
"id": 281429,
"uid": "8d682367-7894-267d-ac29-753b8ba8386e",
"siteId": 48083,
"siteName": "",
"deviceType": {
"category": "Laptop",
"type": "Notebook"
},
},
{
"id": 281429,
"uid": "8d682367-7894-267d-ac29-753b8ba8386e",
"siteId": 48083,
"siteName": "",
"deviceType": {
"category": "Desktop",
"type": "Desktop"
},
}
After the HTTP call I added a Compose (Compose 2) action
body('HTTP_2')?['devices']
Then I was thinking of adding a Compose for each category
length(body('Compose_2')) - length(replace(body('Compose_2'), 'laptop', ''))
length(body('Compose_2')) - length(replace(body('Compose_2'), 'desktop', ''))
length(body('Compose_2')) - length(replace(body('Compose_2'), 'server', ''))
I'm just not sure how to compose that expression for each?
Thanks,
David