0
votes

I am trying to get all workitems, linked to all pull requests in a repo.

First, I run the API Command to get all Pull Requests: https://dev.azure.com/{organization}/{project}/_apis/git/pullrequests?api-version=5.1

That works just fine.

Then Looping through each Pull Request, I try to get all Work Items https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullRequests/{pullRequestId}/workitems?api-version=5.1

Even though I am an Admin, I still get this error: innerException : null message : TF401019: The Git repository with name or identifier {MY Repo ID} does not exist or you do not have permissions for the operation you are attempting. typeName : Microsoft.TeamFoundation.Git.Server.GitRepositoryNotFoundException, Microsoft.TeamFoundation.Git.Server typeKey : GitRepositoryNotFoundException errorCode : 0 eventId : 300

Can Anyone help me figure out how to get these related work items for the pull requests?

API Web Pages:
https://docs.microsoft.com/en-us/rest/api/azure/devops/git/pull%20requests?view=azure-devops-rest-5.1 https://docs.microsoft.com/en-us/rest/api/azure/devops/git/pull%20request%20work%20items/list?view=azure-devops-rest-5.1

1
MAybe this would help: stackoverflow.com/a/50789785/6309VonC

1 Answers

0
votes

I figured out what was wrong.

When using the API call to get the workitems for a given Pull Request, I was using the RepoID field that I got back from the previous command. Instead of using RepoID as the Repo ID in the New Command to get work items, I had to use the Repo Name.

SO the solution is to use this: value.0.repository.name instead of this: value.0.repository.id from the first call to get pull requests.