How to return/$select only required attributes in Graph API response

AzurePixel 21 Reputation points
2020-08-06T21:41:42.24+00:00

I have endpoint below,

https://graph.microsoft.com/beta/deviceManagement/detectedApps/de0783f6a94960672b1bcb37ddf9b8565af/managedDevices

It returns an Array called "value" as follows.


{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#Collection(microsoft.graph.managedDevice)",
"@odata.count": 2,
"value": [
{
"id": "111-0d5d3d0d8921",
"userId": null,
"deviceName": "DESKTOP-XYZ1",
"ownerType": "unknown",
"managedDeviceOwnerType": "unknown",
"managementState": "managed",
"enrolledDateTime": "0001-01-01T00:00:00Z",
},
{
"id": "111-0d5d3d0d8922",
"userId": null,
"deviceName": "DESKTOP-XYZ2",
"ownerType": "unknown",
"managedDeviceOwnerType": "unknown",
"managementState": "managed",
"enrolledDateTime": "0001-01-01T00:00:00Z",
},
]
}


I need only the id attribute in the response, as follows. Is this achievable?


{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#Collection(microsoft.graph.managedDevice)",
"@odata.count": 2,
"value": [
{
"id": "111-0d5d3d0d8921",
},
{
"id": "111-0d5d3d0d8922",
},
]

}

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,436 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AmanpreetSingh-MSFT 56,306 Reputation points
    2020-08-07T05:33:20.13+00:00

    Hello @AzurePixel

    You need to add ?$select=id at the end of your call as shown below:

    https://graph.microsoft.com/beta/deviceManagement/detectedApps/de0783f6a94960672b1bcb37ddf9b8565af/managedDevices?$select=id

    Select parameter can have multiple values as well in comma separated format. For example:

    https://graph.microsoft.com/beta/deviceManagement/detectedApps/de0783f6a94960672b1bcb37ddf9b8565af/managedDevices?$select=id,deviceName

    -----------------------------------------------------------------------------------------------------------

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.