Forum Discussion
chamidu_sumanasekara
Nov 13, 2024Copper Contributor
Azure Git get the PR difference in global diff format
Hi, I am looking for an API or workaround to get the difference of a PR in global diff format. a functionality similar to github /repos/{repo name}/pulls/{PR number}.diff
balasubramanim
Nov 14, 2024Iron Contributor
To get a PR diff in Azure DevOps
1. Get PR Diff JSON - Use this API to get the diff in JSON format
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullRequests/{pullRequestId}/iterations/{iterationId}/diff?api-version=7.1-preview.1
2. Alternative - Compare branches directly
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/diffs/commits?baseVersion={targetBranch}&targetVersion={sourceBranch}&api-version=7.1-preview.1
For a .diff format, parse and convert the JSON response