web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Assigning licenses to new employees using MS Graph API in Power Automate

(0) ShareShare
ReportReport
Posted on by 169

Hi everyone,

 

I am trying to assign licenses to new employees using the Microsoft Graph API in Power Automate. I can retrieve licenses using GET, but I cannot assign them to new employees using POST or PATCH. I get the error "Method Not Allowed."

I have tried the following:

  • I have tried using the POST and PATCH methods to assign licenses to new employees.
  • I am using a tenant administrator account.
  • I have enabled the Microsoft Graph API for my tenant.
  • I have granted the necessary permissions to the Power Automate flow.

     

 

 

 

{
 "uri": "https://graph.microsoft.com/v1.0/users/mkolaric@cizici.onmicrosoft.com/assignedLicenses",
 "method": "POST",
 "headers": {
 "Content-type": "application/json"
 },
 "authentication": {
 "authority": "",
 "tenant": "02447283-2aae-4f75-9b89-ce366e9782e9",
 "audience": "https://graph.microsoft.com",
 "clientId": "62dbfa9c-dd6d-4d75-8c53-06fc754c3f03",
 "secret": "*sanitized*",
 "type": "ActiveDirectoryOAuth"
 },
 "body": {
 "value": [
 {
 "addLicenses": [
 {
 "disabledPlans": [],
 "skuId": "5b631642-bd26-49fe-bd20-1daaa972ef80"
 },
 {
 "disabledPlans": [],
 "skuId": "c42b9cae-ea4f-4ab7-9717-81576235ccac"
 }
 ],
 "removeLicenses": []
 }
 ]
 }
}

 

 

 

 

 

 

 

 

{
 "error": {
 "code": "Request_BadRequest",
 "message": "Specified HTTP method is not allowed for the request target.",
 "innerError": {
 "date": "2024-03-19T08:42:48",
 "request-id": "f1b1c2cc-f83b-4a91-b4bc-88352d61bb50",
 "client-request-id": "f1b1c2cc-f83b-4a91-b4bc-88352d61bb50"
 }
 }
}

 

 

 

 

Has anyone else experienced this issue? How can I assign licenses to new employees using the Microsoft Graph API in Power Automate?

I have the same question (0)
  • Verified answer
    Expiscornovus Profile Picture
    32,859 Most Valuable Professional on at
    Re: Assigning licenses to new employees using MS Graph API in Power Automate

    Hi @Bambula,


    It looks like your Authority field in the Authentication settings is empty. Can you add https://login.microsoftonline.com in that field?

     

    Below is an example which should work (assuming you have assigned the correct Graph API permissions to your app registration in Entra Id, User.ReadWrite.All or Directory.ReadWrite.All).

     

    In this example I am assigning the Microsoft Power Automate Free (f30db892-07e9-47e9-837c-80727f46fd3d) and Microsoft Power Apps Plan 2 Trial (dcb1a3ae-b33f-4487-846a-a640262fadf4) licenses btw.

     

     

     

    {
     "addLicenses": [
     {
     "disabledPlans": [],
     "skuId": "f30db892-07e9-47e9-837c-80727f46fd3d"
     },
     {
     "disabledPlans": [],
     "skuId": "dcb1a3ae-b33f-4487-846a-a640262fadf4"
     }
     ],
     "removeLicenses": []
    }

     

     

     

    assignlicenses_entraid.png

  • Bambula Profile Picture
    169 on at
    Re: Assigning licenses to new employees using MS Graph API in Power Automate

    Hi, @Expiscornovus 

    its works . thanks .

    Bambula_1-1710846752150.png

     

     

  • Lombahdo Profile Picture
    2 on at
    Re: Assigning licenses to new employees using MS Graph API in Power Automate

    Hi @Expiscornovus ,

     

    I also am trying to set this up, and I have it setup exactly to the specs provided but I am still getting HTTP method is not allowed for requested target.

     

    Raw Input:

    {
     "uri": "https://graph.microsoft.com/v1.0/users/67a9cbf3-d55b-47b3-b0d2-be1ba01f683d/assignedLicenses",
     "method": "POST",
     "authentication": {
     "authority": "https://login.microsoftonline.com",
     "tenant": "f28a0d28-f54d-436c-98ba-88837197506d",
     "audience": "https://graph.microsoft.com",
     "clientId": "c58120ab-9fc8-4419-b284-e9ab168d9bf1",
     "secret": "*sanitized*",
     "type": "ActiveDirectoryOAuth"
     },
     "body": {
     "addLicenses": [
     {
     "disabledPlans": [],
     "skuId": "f30db892-07e9-47e9-837c-80727f46fd3d"
     },
     {
     "disabledPlans": [],
     "skuId": ""
     }
     ],
     "removeLicenses": []
     }
    }

     

    Raw Output:

    {
     "statusCode": 405,
     "headers": {
     "Cache-Control": "no-cache",
     "Transfer-Encoding": "chunked",
     "Vary": "Accept-Encoding",
     "Strict-Transport-Security": "max-age=31536000",
     "request-id": "fe8722cd-c0ab-462b-aa01-4271924efb28",
     "client-request-id": "fe8722cd-c0ab-462b-aa01-4271924efb28",
     "x-ms-ags-diagnostic": "{\"ServerInfo\":{\"DataCenter\":\"West US\",\"Slice\":\"E\",\"Ring\":\"4\",\"ScaleUnit\":\"001\",\"RoleInstance\":\"BY1PEPF00003AA0\"}}",
     "x-ms-resource-unit": "1",
     "Date": "Thu, 09 May 2024 20:25:32 GMT",
     "Content-Type": "application/json",
     "Content-Length": "267"
     },
     "body": {
     "error": {
     "code": "Request_BadRequest",
     "message": "Specified HTTP method is not allowed for the request target.",
     "innerError": {
     "date": "2024-05-09T20:25:33",
     "request-id": "fe8722cd-c0ab-462b-aa01-4271924efb28",
     "client-request-id": "fe8722cd-c0ab-462b-aa01-4271924efb28"
     }
     }
     }
    }

     

    I have given my app API delegate access for Directory.ReadWrite.All and User.ReadWrite.All.  

  • Expiscornovus Profile Picture
    32,859 Most Valuable Professional on at
    Re: Assigning licenses to new employees using MS Graph API in Power Automate

    Hi @Lombahdo,

     

    I see you tried adding an empty skuId, can you remove that part of your Body payload and try again to see if that makes a difference?

     

    Change this:

    {
     "addLicenses": [
     {
     "disabledPlans": [],
     "skuId": "f30db892-07e9-47e9-837c-80727f46fd3d"
     },
     {
     "disabledPlans": [],
     "skuId": ""
     }
     ],
     "removeLicenses": []
     }

     

    To this:

    {
     "addLicenses": [
     {
     "disabledPlans": [],
     "skuId": "f30db892-07e9-47e9-837c-80727f46fd3d"
     }
     ],
     "removeLicenses": []
     }

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 650 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 341 Moderator

#3
developerAJ Profile Picture

developerAJ 256

Last 30 days Overall leaderboard