SOLVED

Update Intune Managed Device Category with Microsoft Graph were Failed

Occasional Contributor

I'd failed to update the managed device category in Intune with Microsoft Graph. With the same code, I'd succeeded to update device owner. Parameter below:

 

URL: https://graph.microsoft.com/beta/deviceManagement/managedDevices('XXXXXXXXXX')
Method: PUT

Failed request body:

{ "deviceCategoryDisplayName": "General Purpose" }

 

Succeeded request body:

{ "Owner": "Personal" }

 

"General Purpose" is a custom value. When failed, the server returns an error code and activity id.

How can I fix it?

 

Thank you.
Regards,

4 Replies

Hi,

 

you have to create the category first in Intune before you can assign it to a device:

SNAG-0047.png

 

otherwise you are not seeing it and assignment is not allowed:

SNAG-0048.png


I think this constrained is the same when doing it via graph.

 

best,
Oliver

best response confirmed by Nayuta (Occasional Contributor)
Solution

In addition to what Oliver said, here's how if you want to do it through Graph API:

1.  Create the category

Request URL : https://graph.microsoft.com/beta/deviceManagement/deviceCategories

Request Method: POST

Request Payload: {displayName: "testCategory(displayNameOfCategory)"}

 

Sample response:

{

"@odata.context":"https://graph.microsoft.com/beta/$metadata#deviceManagement/deviceCategories/$entity",

"id":"11111111-1111-1111-1111-111111111111(TakeThisIDItIsYourDeviceCategoryID)",

"displayName":"testCategory",

"description":null

}

Or Get categories if created already

Request URL : https://graph.microsoft.com/beta/deviceManagement/deviceCategories

Request Method: GET

 

Sample response:

{

"@odata.context":"https://graph.microsoft.com/beta/$metadata#deviceManagement/deviceCategories",

"value":[{"id":"11111111-1111-1111-1111-111111111111","displayName":"testCategory","description":null}]

}

2. Set the category for device

Request URL: https://graph.microsoft.com/beta/deviceManagement/managedDevices('22222222-2222-2222-2222-2222222222...

Request Method: PUT

Request Payload: {@odata.id"https://graph.microsoft.com/beta/deviceManagement/deviceCategories/11111111-1111-1111-1111-111111111..."}

 

Sample response: 204

 

Thank you. But, I want to update with Microsoft Graph API (:

Hi @wazha,

 

I'vd done it! Thank you so much!

 

nayuta