Open LeoniSantos opened 4 years ago
Two years late, but aren't you missing a slash in your URL? After "enrollmentProfiles" and before the ('ProfileId')?
I found your post when searching for this issue, or actually not the same, i'm getting an error telling me I have an "invalid profileID" when contacting the API.
I am trying to consume the endpoint below
POST /deviceManagement/depOnboardingSettings/{depOnboardingSettingId}/enrollmentProfiles/{enrollmentProfileId}/updateDeviceProfileAssignment
using
Connect MSGraph Intune SDK
$cred = Get-Credential Connect-MSGraph -Credential $cred -Quiet Update-MSGraphEnvironment -SchemaVersion 'beta' -Quiet
Define Variables
$SerialNumber = "XXXXXXXXXXX" $ProfileId = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' $JSON = @{ "deviceIds" = $SerialNumber } | ConvertTo-Json $URL = "deviceManagement/depOnboardingSettings/XXXXXXXXXXXXXXXXXXXXXXXXXXXX/enrollmentProfiles('$ProfileId')/updateDeviceProfileAssignment"
perform Rest Call
Invoke-MSGraphRequest -HttpMethod POST -Url $URL -Content $JSON
but i am getting error below, does anyone have an idea about what i did wrong? the same json payload using Invoke-RestMethod and endpoint works fine.
Invoke-MSGraphRequest : 400 Bad Request { "error": { "code": "BadRequest", "message": "{\r\n \"_version\": 3,\r\n \"Message\": \"Invalid ODataActionParameter 'deviceIds' - Operation ID (for customer support): 00000000-0000-0000-0000-000000000000 - Activity ID: e45da853-0df9-4753-b020-568f9b0ecf91 - Url: https://fef.msua04.ma nage.microsoft.com/DeviceEnrollmentFE/StatelessDeviceEnrollmentFEService/deviceManagement/depOnboardingSettings%XXXXXXXXXXXXXXXXXXXXXXXXX/enrollmentProfiles%28%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX6 %27%29/microsoft.management.services.api.updateDeviceProfileAssignment?api-version=5019-10-15\",\r\n \"CustomApiErrorPhrase\": \"\",\r\n \"RetryAfter\": null,\r\n \"ErrorSourceService\": \"\",\r\n \"HttpHeaders\": \"{}\"\r\n}", "innerError": { "request-id": "e45da853-0df9-4753-b020-568f9b0ecf91", "date": "2020-04-22T18:49:19" } } } At line:8 char:1