Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graph API bug "assignLicenses" #3229

Closed
OtterKring opened this issue Mar 19, 2025 · 1 comment
Closed

Graph API bug "assignLicenses" #3229

OtterKring opened this issue Mar 19, 2025 · 1 comment
Labels
status:duplicate A duplicate issue type:bug A broken experience

Comments

@OtterKring
Copy link

Describe the bug

Assigning and removing licenses from users has stopped working this monday, regardless if I use Microsoft.Graph module 2.25, 2.26.1 or Invoke-MgGraphRequest.

Error sources I can rule out so far:

  • missing permissions. My application permissions have not changed
  • typos. I am using the same function for years now and the problem started this week, manual or with the function.

This is the code I use for removing licenses:

... | %{get-mguser -userid $_ -Property id,assignedlicenses | %{Set-MgUserLicense -UserId $_.id -RemoveLicenses $_.assignedlicenses.skuid -AddLicenses @() }}

I get the following error message:

Set-MgUserLicense_AssignExpanded: One or more parameters of the operation 'assignLicense' are missing from the request payload. The missing parameters are: addLicenses.

Status: 400 (BadRequest)
ErrorCode: Request_BadRequest
Date: 2025-03-19T07:43:08

Headers:
Cache-Control                 : no-cache
Vary                          : Accept-Encoding
Strict-Transport-Security     : max-age=31536000
request-id                    : a7dbed89-d1e9-438b-83c5-626efe58b8c5
client-request-id             : 34c9eed1-b70b-4390-bb2b-f5a0d1568c58
x-ms-ags-diagnostic           : {"ServerInfo":{"DataCenter":"West Europe","Slice":"E","Ring":"5","ScaleUnit":"003","RoleInstance":"AM1PEPF0003D2F2"}}
x-ms-resource-unit            : 1
Date                          : Wed, 19 Mar 2025 07:43:08 GMT


  Recommendation: See service error codes: https://learn.microsoft.com/graph/errors

When adding a license like this:

... | %{get-mguser -userid $_ | %{Set-MgUserLicense -userid $_.id -AddLicenses @(@{skuid='f30db892-07e9-47e9-837c-80727f46fd3d'}) -RemoveLicenses @()}}

I get this(same) error message:

Set-MgUserLicense_AssignExpanded: One or more parameters of the operation 'assignLicense' are missing from the request payload. The missing parameters are: removeLicenses.

Status: 400 (BadRequest)
ErrorCode: Request_BadRequest
Date: 2025-03-19T08:15:59

Headers:
Cache-Control                 : no-cache
Vary                          : Accept-Encoding
Strict-Transport-Security     : max-age=31536000
request-id                    : 7c9e32c5-be69-4317-8b6b-8416a538d9d0
client-request-id             : f93be6b9-6939-49cd-be60-7a21201c7030
x-ms-ags-diagnostic           : {"ServerInfo":{"DataCenter":"West Europe","Slice":"E","Ring":"5","ScaleUnit":"011","RoleInstance":"AM2PEPF0001BE7C"}}
x-ms-resource-unit            : 1
Date                          : Wed, 19 Mar 2025 08:15:59 GMT


  Recommendation: See service error codes: https://learn.microsoft.com/graph/errors

Invoke-MgGraphRequest

$l = 'f30db892-07e9-47e9-837c-80727f46fd3d'
$body = @{addLicenses = @(@{skuid = $l}); removeLicenses = @()}
Invoke-MgGraphRequest -Method POST -Uri "https://graph.microsoft.com/v1.0/users/$((get-mguser -userid xxx).id)/assignLicense" -Body ($body | ConvertTo-Json)

Error message:

Invoke-MgGraphRequest: POST https://graph.microsoft.com/v1.0/users/e93c0692-6f80-48d7-a449-350c21eac1d1/assignLicense
HTTP/2.0 400 Bad Request
Cache-Control: no-cache
Vary: Accept-Encoding
Strict-Transport-Security: max-age=31536000
request-id: f9ad51d8-1899-46ec-9c02-2a58bcd8d2a8
client-request-id: ea230e52-f525-4b60-92e2-c6fba34dfc00
x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"West Europe","Slice":"E","Ring":"5","ScaleUnit":"005","RoleInstance":"AM4PEPF0002BAC3"}}
x-ms-resource-unit: 1
Date: Wed, 19 Mar 2025 07:54:54 GMT
Content-Type: application/json

{"error":{"code":"Request_BadRequest","message":"Invalid value specified for property 'skuId' of resource 'AssignedLicense'.","details":[{"code":"InvalidValue","message":"Invalid value specified for property 'skuId' of resource 'AssignedLicense'.","target":"skuId"}],"innerError":{"date":"2025-03-19T07:54:54","request-id":"f9ad51d8-1899-46ec-9c02-2a58bcd8d2a8","client-request-id":"ea230e52-f525-4b60-92e2-c6fba34dfc00"}}}

using Set-MgBetaUserLicense (Module 2.26.1)

Same issue.

Expected behavior

Well, licenses should be added or removed. 🤷‍♂️

How to reproduce

See "Describe the bug"

SDK Version

2.25, 2.26.1

Latest version known to work for scenario above?

I don't think it is related to the modules, but to the API itself

Known Workarounds

Use admin.microsoft.com. Tedious if you have a lot of users to process.

Debug output

Click to expand log ```
</details>


### Configuration

Name Value


PSVersion 7.5.0
PSEdition Core
GitCommitId 7.5.0
OS Microsoft Windows 10.0.26100
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0


### Other information

The behavior started for me on monday, March 17th. There was no upgrade to Powershell or the Graph module during this time, no change in permissions or the used function.
@OtterKring OtterKring added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Mar 19, 2025
@OtterKring OtterKring changed the title Graph API bug "assigneLicenses" Graph API bug "assignLicenses" Mar 19, 2025
@timayabi2020
Copy link
Contributor

Hi @OtterKring apologies for the inconvenience. This issue was already reported here #3201 and the fix for it will be available in the next release. I'll therefore close this one as a duplicate of that one.

@timayabi2020 timayabi2020 added status:duplicate A duplicate issue and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Mar 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:duplicate A duplicate issue type:bug A broken experience
Projects
None yet
Development

No branches or pull requests

2 participants