2
votes

In our APP we have the user token for a user on Azure DevOps. We use this to perform certain actions in the Azure DevOps instance using REST APIs. In order to ignore webhooks triggered by actions performed by this particular user, we need to know the user's email. Is there an API that can provide that?

I tried the GET https://app.vssps.visualstudio.com/_apis/profile/profiles/{id}?api-version=5.1 with "me" in place of {id} as suggested by their documentation https://docs.microsoft.com/en-us/rest/api/azure/devops/profile/profiles/get?view=azure-devops-rest-5.1 but it throws "Resource cannot be found" error.

1

1 Answers

0
votes

we need to know the user's email. Is there an API that can provide that?

For this issue , you can use Users - List rest api to achieve this .

Sample Request:

GET https://vssps.dev.azure.com/{organization}/_apis/graph/users?api-version=5.1-preview.1

Sample Response:

{
      "subjectKind": "user",
      "metaType": "member",
      "domain": "LOCAL AUTHORITY",
      "principalName": "TeamFoundationService (TEAM FOUNDATION)",
      "mailAddress": "[email protected]",
      "origin": "vsts",
      "originId": "00ca946b-2fe9-4f2a-ae2f-40d5c48001bc",
      "displayName": "TeamFoundationService (TEAM FOUNDATION)",
      "_links": {
        "self": {
          "href": "https://vssps.dev.azure.com/Fabrikam/_apis/Graph/Users/acs.Nzc4OWYwOWQtZTA1My00ZjJlLWJkZWUtMGM4Zjg0NzZhNGJj"
        },
        "memberships": {
          "href": "https://vssps.dev.azure.com/Fabrikam/_apis/Graph/Memberships/acs.Nzc4OWYwOWQtZTA1My00ZjJlLWJkZWUtMGM4Zjg0NzZhNGJj"
        },
        "membershipState": {
          "href": "https://vssps.dev.azure.com/Fabrikam/_apis/Graph/MembershipStates/acs.Nzc4OWYwOWQtZTA1My00ZjJlLWJkZWUtMGM4Zjg0NzZhNGJj"
        },
        "storageKey": {
          "href": "https://vssps.dev.azure.com/Fabrikam/_apis/Graph/StorageKeys/acs.Nzc4OWYwOWQtZTA1My00ZjJlLWJkZWUtMGM4Zjg0NzZhNGJj"
        },
        "avatar": {
          "href": "https://dev.azure.com/Fabrikam/_apis/GraphProfile/MemberAvatars/acs.Nzc4OWYwOWQtZTA1My00ZjJlLWJkZWUtMGM4Zjg0NzZhNGJj"
        }
      },
      "url": "https://vssps.dev.azure.com/Fabrikam/_apis/Graph/Users/acs.Nzc4OWYwOWQtZTA1My00ZjJlLWJkZWUtMGM4Zjg0NzZhNGJj",
      "descriptor": "acs.Nzc4OWYwOWQtZTA1My00ZjJlLWJkZWUtMGM4Zjg0NzZhNGJj"
    }

You can get the user's email from the mailAddress variable in the response body.By specifying the descriptor parameter in the Users-Get rest api, you can get the details of a specific user.