I am trying to pull code review reports from the TFSGIT/VSTS, but I don't see anything out of the box. The 3rd part code review tools like "ReviewAssistant" works great but they are not integrated with the Pull Request. It decouples code review to pull request. I would like to get reports from the PullRequest code comments.
Asked
Active
Viewed 470 times
1 Answers
0
You can pull data from TFS with Rest API.
To get the PR code comments you can use the Pull Request Threads - List.
The request is:
https://{instance}/{collection}/{project}/_apis/git/repositories/{repositoryId}/pullRequests/{pullRequestId}/threads?api-version=4.1
In the JSON response, you will get the comments and the comment location in the code (line number):
"comments": [
{
"id": 1,
"parentCommentId": 0,
"author": {
"displayName": "Shayki Abramczyk",
"url": "https://spsprodweu3.vssps.visualstudio.com/Ac256a93d-7cea-4070-xxxxxxxxx/_apis/Identities/7a9a9b44-a2f1-6dfd-a7f6-xxxxxxxxxx",
"_links": {
"avatar": {
"href": "https://dev.azure.com/xxxxxx/_apis/GraphProfile/MemberAvatars/msa.N2E5YTlxxxxxxxxxxxxxxx"
}
},
"id": "7a9a9b44-a2f1-6dfd-a7f6-xxxxxxxxxx",
"uniqueName": "xxxxxxxx",
"imageUrl": "https://dev.azure.com/xxxxxxxx/_api/_common/identityImage?id=7a9a9b44-a2f1-6dfd-a7f6-xxxxxxxxxx",
"descriptor": "msa.N2E5YTliNDQtYTJmMS03ZGZkLWE3Zjxxxxxxxxxxx"
},
"content": "test comment",
"publishedDate": "2019-02-25T11:11:03.45Z",
"lastUpdatedDate": "2019-02-25T11:11:03.45Z",
"lastContentUpdatedDate": "2019-02-25T11:11:03.45Z",
"commentType": "text",
"usersLiked": [
]
}
],
"status": "active",
"threadContext": {
"filePath": "/SampleForVSTS/Program.cs",
"leftFileStart": {
"line": 14,
"offset": 1
},
"leftFileEnd": {
"line": 14,
"offset": 10
}
},
As you can see there is a comment test comment
at line 14
in the file SampleForVSTS/Program.cs
.
You can write simple code in any language to get the data with Rest API.

Shayki Abramczyk
- 36,824
- 16
- 89
- 114
-
Is there an API to get comments for developer/reviewer? – bomaboom May 04 '19 at 09:00
-
What do you mean? is not what I answered? – Shayki Abramczyk May 05 '19 at 06:53
-
It says {pullRequestId} as one of the parameters. I want 2 reports. 1.all comments received by the developer including all pull requests. 2. All comments given by reviewer for all pull requests. – bomaboom May 08 '19 at 04:14
-
Try to play with the API of Get Pull Requests, then iterate them and get the comments. – Shayki Abramczyk May 08 '19 at 05:24