I'm trying to add a user to my Azure tenant's Active Directory.
I'm using Microsoft Graph API
. The same one exposed through Graph Explorer here.
The problem is that no matter what serviceRoot
URI I pass, I'm getting an exception.
I successfully get a token in GetTokenForApplication
method:
ActiveDirectoryClient activeDirectoryClient = new ActiveDirectoryClient(serviceRoot,
async () => await GetTokenForApplication());
However, when I call:
await activeDirectoryClient.Users.AddUserAsync(aadUser);
It throws this exception:
"{\r\n
\"error\": {\r\n
\"code\": \"BadRequest\",\r\n
\"message\": \"Query parameter api-version not allowed\",\r\n
\"innerError\": {\r\n
\"request-id\": \"57327a85-8320-4363-b5f9-aeacdf782861\",\r\n
\"date\": \"2019-05-30T21:59:55\"\r\n
}\r\n
}\r\n
}"
This is the serviceRoot
URI I'm using: "https://graph.microsoft.com/v1.0"
What URI should I pass in serviceRoot?
Is ActiveDirectoryClient
compatible with Microsoft Graph
? I ask because the sample where I saw ActiveDirectoryClient
being used was using Azure AD Graph API
.
This blog post shows the difference between the old Azure AD Graph API
and the new Microsoft Graph API
. By the way: Microsoft advises us to use Microsoft Graph API
because all new development is going to be concentrated on it.