简体   繁体   中英

Azure DevOps - Update user profile via Api

I'm trying to perform a bulk update on a bunch of user profiles (displayName, mail, etc.) without having the users credentials instead with the highest privileges in Azure Active Directory and DevOps via the Azure DevOps REST API. As the DevOps stays not in sync with the AAD.

It looks like the Update method of a user can only map users to a new identity .

This is what I have tried so far:

private Task<HttpResponseMessage> PatchVstsUser(vssps.dev.azure.com.VstsUser user)
{

    var patchUser = new
    {
        displayName = user.Name,
        mailAddress = user.Mail,
        originId = user.AadId
    };

    return _devOpsGraphApi.PatchAsync($"users/{user.GraphDescriptor}?api-version=5.1-preview.1", patchUser);
 }

The API response with a 200 repsonse code but the acutal display name is not updated.

How can I update eg the display name of a user using the Azure DevOps Rest API?

From network tab i was able to get the api fro updating user in Azure devops.

在此输入图像描述

Here is the request :

Request URL: https://####.###.azure.com/_apis/User/User
Request Method: PATCH
Status Code: 200 
Remote Address: ##.###.#.###:###
Referrer Policy: no-referrer-when-downgrade

Similarly you can get it for your organization.

Please note that its not a recommended way to updated the user. Assuming your azure devops account is tagged to Azure Active directory, so you should be able to user graph API to updated user profile using below url.

PATCH /users/{id | userPrincipalName}

https://docs.microsoft.com/en-us/graph/api/user-update?view=graph-rest-1.0&tabs=cs

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM