I'm trying to find a way to add a branch as a link in Azure DevOps through an application I'm building (Basically just this, but within a C# console app).
I'm becoming familiar with the VisualStudio Services and TeamFoundation .NET libraries and have tried, as an example, to grab a work item with one of these links already created via the DevOps UI and port it to over to another work item like so:
var workItemWithBranchLink = await _WorkItemTrackingHttpClient.GetWorkItemAsync(3985, expand: WorkItemExpand.Relations);
var workItemWithoutBranchLink = await _WorkItemTrackingHttpClient.GetWorkItemAsync(3988, expand: WorkItemExpand.Relations);
var document = new JsonPatchDocument();
document.Add(new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/relations",
Value = workItemWithBranchLink.Relations
});
await _WorkItemTrackingHttpClient.UpdateWorkItemAsync(document, (int)workItemWithoutBranchLink.Id);
However, this throws an exception
Microsoft.VisualStudio.Services.WebApi.Patch.PatchOperationFailedException: 'Work item patch does not support patching the top level property at path /relations.
Since workItemWithoutBranchLink.Relations
is null I'm not sure how else I could patch it.
Any ideas?