MS Graph - Assign license to user

Ayan Usmani 171 Reputation points
2022-09-29T06:09:23.34+00:00

I am assigning Microsoft 365 E3 whose SKU is "05e9a617-0261-4cee-bb44-138d3ef5d965 " using assignLicense API.

This works fine sometime but sometime I am getting this error :

'message': 'Subscription with SKU 05e9a617-0261-4cee-bb44-138d3ef5d965 does not have any available licenses.

Let me know, why this is happening & what needs to be taken care while using this API.

Here is the API :

POST - https://graph.microsoft.com/v1.0/users/{userPricipalName}/assignLicense

body :

{
"addLicenses": [
{
"skuId": "05e9a617-0261-4cee-bb44-138d3ef5d965"
}
],
"removeLicenses": [ ]
}

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,776 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,777 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Zehui Yao_MSFT 5,831 Reputation points
    2022-09-30T08:49:48.567+00:00

    Hi @Ayan Usmani ,
    Per my test, before using the API, you must have the relevant license in your tenant that you can see in AD.

    246431-untitled2.png

    Then you can use the List subscribedSkus API: GET /subscribedSkus to list the license that you have subscribed to. You can check if the Sku: 05e9a617-0261-4cee-bb44-138d3ef5d965 is being subscribed. And the skuId property can be used to assign license.

    246401-untitled.png

    I tested it locally and then made it run successfully by adding the disabledPlans property, the value of which is the servicePlanId in the response of the /subscribedSkus endpoint.

    Hope this helps. Wish you all the best.

    246403-image.png
    246318-untitled1.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

  2. Ayan Usmani 171 Reputation points
    2022-10-04T18:32:03.737+00:00

    Thanks @Zehui Yao_MSFT .... i have done the same.

    I had fetched the details of license and I can see that we have license with skuID - 05e9a617-0261-4cee-bb44-138d3ef5d965 .
    247523-image.png

    But when I am trying to add the same license for another user it throws me the below error :
    247553-image.png

    Do let me know what's going wrong over here.

    1 person found this answer helpful.