'Get pull request by ID - ADO API returns null in few properties of response

I am using this ADO API - https://docs.microsoft.com/en-us/rest/api/azure/devops/git/pull-requests/get-pull-request-by-id?view=azure-devops-rest-6.0

I make this call through azure SDK at backend. The call is successful and returns 200 status and a response.

I need to use these properties from res -

  1. LastMergeCommit
  2. LastMergeSourceCommit
  3. LastMergeTargetCommit

These three properties are itself json and have multiple sub-properties. But apart from 'Url' and 'CommitId' all other sub-properties are coming out as null. I need to use Committer sub-property in my code base. So If it comes as null - then I will need to make separate API call to just get this data which is not performance efficient.

Any alternative/idea about the issue?



Solution 1:[1]

Please check Get Pull Requests By Project With optional parameters:

GET https://dev.azure.com/{organization}/{project}/_apis/git/pullrequests?searchCriteria.creatorId={searchCriteria.creatorId}&searchCriteria.includeLinks={searchCriteria.includeLinks}&searchCriteria.repositoryId={searchCriteria.repositoryId}&searchCriteria.reviewerId={searchCriteria.reviewerId}&searchCriteria.sourceRefName={searchCriteria.sourceRefName}&searchCriteria.sourceRepositoryId={searchCriteria.sourceRepositoryId}&searchCriteria.status={searchCriteria.status}&searchCriteria.targetRefName={searchCriteria.targetRefName}&maxCommentLength={maxCommentLength}&$skip={$skip}&$top={$top}&api-version=6.0

Or Get Pull Requests :

GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests?searchCriteria.creatorId={searchCriteria.creatorId}&searchCriteria.includeLinks={searchCriteria.includeLinks}&searchCriteria.repositoryId={searchCriteria.repositoryId}&searchCriteria.reviewerId={searchCriteria.reviewerId}&searchCriteria.sourceRefName={searchCriteria.sourceRefName}&searchCriteria.sourceRepositoryId={searchCriteria.sourceRepositoryId}&searchCriteria.status={searchCriteria.status}&searchCriteria.targetRefName={searchCriteria.targetRefName}&maxCommentLength={maxCommentLength}&$skip={$skip}&$top={$top}&api-version=6.0

to see if it works well.

For parameters description, you can refer to :

  1. Get Pull Requests By Project
  2. Get Pull Requests

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kangcheng Jin-MSFT