Prashanth Subramanian
Prashanth Subramanian

Reputation: 653

VSTS REST API for C# - How to get linked commits from workitem?

I'm trying to get commits linked to work items and do not want to go the route of using the TFS SDK API. Which would be something like GetWorkItem and then Get External Links. But since it has some dependencies that we don't want to continue using. I want to try and do the same thing using VSTS REST API. But I haven't been able to find a way to do it. This is the API,

https://learn.microsoft.com/en-us/rest/api/vsts/wit/artifact%20link%20types/list?view=vsts-rest-4.1

Is there some functionality implemented that I just haven't been able to find, or has it just not been implemented? (seems weird, because this is a common use-case to get objects linked to a workitem).

Thanks!

Upvotes: 1

Views: 896

Answers (1)

Weiwei
Weiwei

Reputation: 3766

The API that you provided is used to get linked artifacts' type, not specific artifacts information. In current VSTS, we cannot get a work item linked artifacts directly. We need to use GetWorkItem API with $expand parameter to get all relations in a work item. https://{VSTSAccount}.visualstudio.com/{ProjectName}/_apis/wit/workitems/{WorkItemId}?$expand=relations&api-version=5.0-preview.3

Then loop the Relations field in work item to filter the Commits type to get the related commits in work item.

Upvotes: 1

Related Questions