Describe the different steps for connecting Magic xpi with AzureAD using REST API
1/ Check that you get OAuth2 token from login.microsoftonline using Postman
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/AD_MG7.png)
(*) client_id, clientsecret, resource, tenantid, callback URL and scope are retrieved from azure portal (https://portal.azure.com)
(**) Check the API permissions
![](https://france.magicsoftware.com/blog/wp-content/uploads/2023/11/AZUREAD_XPI4-1024x555.png)
2/Check that you can get the Users List from Postman
![](https://france.magicsoftware.com/blog/wp-content/uploads/2023/11/AZUREAD_XPI3-1-1024x773.png)
2/ Create a REST Client Magic xpi resource (Project=>Settings=>Resources)
Define a REST resource with OAuth2 security enabled with all credentials
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/AD_MG1-1-1024x537.png)
Define 2 Paths : /users and /users/{id}
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/AD_MG2-1-1024x537.png)
3/ Drag and Drop a REST Client Connector linked to the resource and configure the connector to call users with Get operation.
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/AD_MG3.png)
7/ Use Datamapper component to parse the Json response and create a flat file with 3 columns (userPrincipalName, id, mail)
![](https://france.magicsoftware.com/blog/wp-content/uploads/2023/11/AZUREAD_XPI11-1024x333.png)
8/ To create a User, you need to update a json message with different attributes using a flow data component or a datamapper
(*) to get the Json format, please the microsoft documentation (Create User – Microsoft Graph v1.0 | Microsoft Learn)
![](https://france.magicsoftware.com/blog/wp-content/uploads/2023/11/AZUREAD_XPI12.png)
![](https://france.magicsoftware.com/blog/wp-content/uploads/2023/11/AZUREAD_XPI13-1024x429.png)
9/ Drag and Drop a REST Client connector and call users with Post operation
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/AD_MG4.png)
If the user is created successfully, you should receive status 201 in the variable F.StatusCode and a json response with the user id
![](https://france.magicsoftware.com/blog/wp-content/uploads/2023/11/AZUREAD_XPI16-1024x252.png)
10/ If you want to delete, update an AD user, you can use Operations : Delete, Patch and pass the userid in the path ( /users/{id})
Below an example for deleting the user.
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/AD_MG5-1024x719.png)
![](https://france.magicsoftware.com/blog/wp-content/uploads/2023/11/AZUREAD_XPI18-1024x175.png)
11/ Documentation Reference :
https://learn.microsoft.com/en-us/graph/api/resources/users?view=graph-rest-1.0