Reputation: 850
I am trying to create a new user in Azure DevOps using Rest API C# and by debugging the code I am not seeing any error and the user information were showing correct after I get result of the created new user. My issue is that the user is NOT saved after the application is completed and I do not see the user in Azure DevOps. When I check the status of the task it is WaitingForActivation.
Here is the code I am using and please advise what is wrong:
VssConnection connection = new VssConnection(new Uri(uri), new VssBasicCredential(string.Empty, personalAccessToken));
GraphHttpClient graphClient = connection.GetClient<GraphHttpClient>();
GraphUserMailAddressCreationContext usr = new GraphUserMailAddressCreationContext();
usr.MailAddress = "[email protected]";
GraphUser u = graphClient.CreateUserAsync(usr).Result;
Upvotes: 0
Views: 1085
Reputation: 76760
Creating a New User in Azure DevOps using Rest API
According to your code segment, it seems you are adding a user via Graph. But add a user via Graph does not give them access to the account, the user has to be materialized and added to the appropriate projects, groups etc.
To add a user, I suggest you can use another API User Entitlements - Update User Entitlement with following request body:
[
{"from":"",
"op":0,
"path":"/projectEntitlements",
"value":{"projectRef":{"id":"<MyProjectID>"},"group":{"groupType":3}}
}
]
You can check my another thread for some more details.
Hope this helps.
Upvotes: 1