I have a build pipeline with a trigger on new branch creation. The trigger works fine with me creating a new branch and linking a workitem task to the new branch.
I have tried to run the query through the API to retrieve the workitem associated to the build but it always comes back blank. I can retrieve the list of workitems in the project no problem.
The URI I am using is:
https://dev.azure.com/{instance}/{project}/_apis/build/builds/{build id}/workitems?api-version=6.0
This returns a blank value. If I remove the "workitems" then I get a list of all the builds with one of the entries matching the build id. The PAT I am using has full access to the project (currently testing so have not been specific for the access).
This is the last step for me to complete and I can piece the whole puzzle.
UPDATE1: I have now noticed that in the pipeline log there is no related work item even though I create the branch from within the work item.
UPDATE2: I notice if I do a commit and associated the work item then the build lists the related work item. Does not appear to work when creating a new branch, only comitting to that new branch