Closed SirHenryIII closed 2 years ago
Hey @SirHenryIII,
Thanks for raising this.
Any chance you could share the json you used in Graph Explorer to help identify where the inconsistency may be?
Sure, I picked this from the WindowsAutoPilotIntune PowerShell Module:
{
"@odata.type": "#microsoft.graph.importedWindowsAutopilotDeviceIdentity",
"groupTag": "$groupTag",
"serialNumber": "$serialNumber",
"productKey": "",
"hardwareIdentifier": "$hardwareIdentifier",
"assignedUserPrincipalName": "$assignedUser",
"state": {
"@odata.type": "microsoft.graph.importedWindowsAutopilotDeviceIdentityState",
"deviceImportStatus": "pending",
"deviceRegistrationId": "",
"deviceErrorCode": 0,
"deviceErrorName": ""
}
}
But I reduced it to this and it was also working fine.
{
"@odata.typ": "#microsoft.graph.importedWindowsAutopilotDeviceIdentity",
"hardwareIdentifier": "xxxxx"
}
Thats the endpoint I used: https://graph.microsoft.com/v1.0/deviceManagement/importedWindowsAutopilotDeviceIdentities
Thanks for this @SirHenryIII,
Any chance the function works if you change from
HardwareIdentifier = Encoding.ASCII.GetBytes("xxxxx"),
to
HardwareIdentifier = Convert.FromBase64String("xxxxx"),
My understanding is that the first scenario may cause the corruption of the intended payload as Encoding.ASCII.GetBytes
is ideally meant for text encoding and you would need to use the latter if you have base64encoded string.
Hey @andrueastman , that was an easy fix for my issue. It's working fine now. Did I missed any docs that describe the data type?
Hey @SirHenryIII,
The data type is a binary data type for the HardwareIdentifier
outlined in the documentation at the link below.
The issue was caused by incorrect encoding of the binary data as explained in the SO Answer.
Closing this for now. Feel free to create a new issue/re-open in the event of any other question/issue.
Describe the bug I'm using version 4.24.0 in a .NET 4.8 Project. When I try to register a device in Autopilot I get an error and I'm unable to get it up and running.
To Reproduce This is the basic function that I created to test the function
Expected behavior I expect that the device is registered within autopilot but actually I just receiver an error. I can create a json on my own and submit it with the Graph Explorer without an issue.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context I tried a different set of properties within the deviceInformation, so all the commented properties were tested as well