1
votes

I have a question about the following API: https://docs.microsoft.com/en-us/rest/api/azure/devops/graph/users/get?view=azure-devops-rest-5.1

This is the "Users-Get" API under DevOps --> Graph. One of the three input parameters in a webrequest using this API is the "userDescriptor" one, specified as "The descriptor of the desired user." The example provided in the documentation is not helpful in understanding how to use this parameter.

I'm trying to "Get" a specific user and I was wondering how I could use this parameter to do so, ideally through specifying the UPN. I'm specifically wondering if 1. This is possible, and 2. If so, what the syntax is.

Your help is appreciated!

1
Are you blocking on could not get user's descriptor? As far as I know, both UPN and VSID can not be used in this Graph api. You can only use descriptor as parameter value.Merlin Liang
Does my answer work for you? Do you need any additional help?Tomasz Kaniewski
@TomaszKaniewski Yes, thank you! I marked it as answer, thank you for your help.samvanderjagt

1 Answers

2
votes

Use Subject Query from Azure DevOps API Graph

Ref: https://docs.microsoft.com/en-us/rest/api/azure/devops/graph/subject%20query/query?view=azure-devops-rest-6.0

Define the body like this:

{
    "query": "Term to search (e.g. UPN)",
    "subjectKind": [ "User" ]
}

In the result you can find all information about the user that you would get from GET USER endpoint.

{
    "count": 1,
    "value": [
        {
          "subjectKind": "user",
          "domain": "45aa3d2d-7442-473d-b4d3-3c670da9dd96",
          "principalName": "[email protected]",
          "mailAddress": "[email protected]",
          "origin": "aad",
          "originId": "55c8c7b6-7ace-43bc-918f-304dfa2b6317",
          "displayName": "Jia-hao Tseng",
          "_links": {
            "self": {
              "href": "https://vssps.dev.azure.com/Fabrikam/_apis/Graph/Users/aad.MDA0NzBlMzQtZGE2MS03YTY5LWJkOTYtNDg3YTg0OWVjNTU4"
            },
            "memberships": {
              "href": "https://vssps.dev.azure.com/Fabrikam/_apis/Graph/Memberships/aad.MDA0NzBlMzQtZGE2MS03YTY5LWJkOTYtNDg3YTg0OWVjNTU4"
            },
            "membershipState": {
              "href": "https://vssps.dev.azure.com/Fabrikam/_apis/Graph/MembershipStates/aad.MDA0NzBlMzQtZGE2MS03YTY5LWJkOTYtNDg3YTg0OWVjNTU4"
            },
            "storageKey": {
              "href": "https://vssps.dev.azure.com/Fabrikam/_apis/Graph/StorageKeys/aad.MDA0NzBlMzQtZGE2MS03YTY5LWJkOTYtNDg3YTg0OWVjNTU4"
            },
            "avatar": {
              "href": "https://dev.azure.com/Fabrikam/_apis/GraphProfile/MemberAvatars/aad.MDA0NzBlMzQtZGE2MS03YTY5LWJkOTYtNDg3YTg0OWVjNTU4"
            }
          },
          "url": "https://vssps.dev.azure.com/Fabrikam/_apis/Graph/Users/aad.MDA0NzBlMzQtZGE2MS03YTY5LWJkOTYtNDg3YTg0OWVjNTU4",
          "descriptor": "aad.MDA0NzBlMzQtZGE2MS03YTY5LWJkOTYtNDg3YTg0OWVjNTU4"
        }
    ]
}