Register an application on Azure AD using MS Graph API

Ayush Sharma 106 Reputation points
2021-07-29T10:11:05.207+00:00

Hi,

I am trying to register an application on the azure ad using the Graph API calls.

I am using the postman to hit the APIs and I have admin access in Azure.

So Far I have tried the following things

  1. I registered an application manually on Azure AD using this doc- https://learn.microsoft.com/en-us/azure/databricks/dev-tools/api/latest/aad/service-prin-aad-token. (I gave all the required permissions to my application)
  2. I am fetching the token using the service to service call client credentials- https://learn.microsoft.com/en-us/azure/active-directory/azuread-dev/v1-oauth2-client-creds-grant-flow.
  3. After getting the token I pass it in the Authorization and hit the MS graph Create Application endpoint. https://learn.microsoft.com/en-us/graph/api/application-post-applications?view=graph-rest-1.0&tabs=http.
  4. But In the postman, I am not getting any response body. I have checked my Azure Tenant but I am not able to find any newly Registered App.

For Token service(Get)
Endpoint- https://login.microsoftonline.com/{my-tenant-id}/oauth2/token
body-
grant_type:**client_credentials
**client_id:
{app-id}
scope:**https://graph.microsoft.com/.default
**client_secret:
{secret}
//resource:https://graph.microsoft.com
Response success(200) with token

For Create App(POST)
https://graph.microsoft.com/v1.0/applications
body: {
"displayName": "Created with MS Graph API"
}
Authorization: Bearer {token}
Response: Nothing is showing in response

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,588 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,466 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ayush Sharma 106 Reputation points
    2021-07-30T07:23:06.523+00:00

    I found the solution, In the API Header, I was specifying the Content-Length= 67 which was not required. Now I am able to get the Success response

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. AmanpreetSingh-MSFT 56,306 Reputation points
    2021-07-30T07:15:04.857+00:00

    Hi @Ayush Sharma · Thank you for reaching out.

    Could you please try decoding your Access Token at https://jwt.ms and confirm if below application permissions are present under Roles claim:
    119220-image.png

    If these permissions are not present, go to Azure Portal and open the application, that you are using to acquire the token. Under the application permissions blade, please add below Application Permissions under API Permissions blade of the application and Grant Admin consent.
    119288-image.png

    Once you have these permissions in the token, pass it as bearer token to make the POST call to create the application.

    -----------------------------------------------------------------------------------------------------------

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.