Q:

VSTS Pull request API - how to get the IdentityRef

I am using VSTS Pullrequest create API method to automate the PR creation, in the request i need to provide various IdentityRef id values for createdby/autocompleteby/reviewers properties. In my case all i have is user details (like full name, email address - user1@domain.com ), in this case how do i retrieve the IdentityRef Guid so that i can pass it to PR Create API.
https://docs.microsoft.com/en-us/rest/api/azure/devops/git/pull%20requests/create?view=azure-devops-rest-5.0
Any help is appreciated.

A:

1) Use Graph - List Users, but also check for a X-MS-ContinuationToken response header to determine if there is still additional paged data to be retrieved. If so, resend the request with the continuation token value until all values are returned: 

GET https://vssps.dev.azure.com/{organization}/_apis/graph/users?api-version=5.0-preview.1, followed by 
GET https://vssps.dev.azure.com/{organization}/_apis/graph/users?continuationToken={continuationToken}&api-version=5.0-preview.1

(I'm wondering if this is why you are only getting 500 users per your comment above. Unfortunately the documentation doesn't list the max page size for this API. If you are using the continuation token and all users are not being returned, that sounds like an API bug to me.) 
2) Use Get User Entitlements. This provides top and skip parameters. The top parameter has a 10000 record limit per the documentation. 

GET https://vsaex.dev.azure.com/{organization}/_apis/userentitlements?top=10000&api-version=5.0-preview.2

