3
votes

I'm trying to pull policies from the git/policy rest api following this article:

https://docs.microsoft.com/en-us/rest/api/azure/devops/git/policy%20configurations/list?view=azure-devops-rest-5.0

When I invoke:

https://dev.azure.com/{organization}/{project}/_apis/git/policy/configurations?api-version=5.0-preview.1

I get a response of: {"count":0,"value":[]}

There are branch policies defined in the project I was trying.

Interestingly if I try the policy/configurations api:

https://docs.microsoft.com/en-us/rest/api/azure/devops/policy/configurations/list?view=azure-devops-rest-5.0#policyconfiguration

https://dev.azure.com/{organization}/{project}/_apis/policy/configurations?api-version=5.0-preview.1

I do get policies back. I haven't tried providing any parameters yet, but the documentation indicates "repositoryId unset, refName unset: returns all policy configurations that are defined at the project level" and their example uri shows no parameters in the query string.

I see this api is in preview. Does it not work at all currently or am I just missing something? I'm trying to use the git/policy configurations api because the policy/configurations api article indicates to "use the /_apis/git/policy/configurations API, which provides first class scope filtering support."

1

1 Answers

1
votes

MS got back to me:

"The new git/policy API (with no parameters) scopes the return data to only the top level policies applied to the current project. And it doesn’t return the “child policies” i.e. for all repository IDs/refNames. You need to specify the repository id and ref name to see the policies."