How do we specify the "type": param when we create a new azure branch policy?

Renjini Kamala 0 Reputation points

Hi Team,

I am trying to create a Azure policy using Azure rest API.And I am using post man to send the request with the sample JSON payload but I keep getting 400 error stating the below:

Error Response

    "count": 1,
    "value": {
        "Message": "Error converting value \"3\" to type 'System.Guid'. Path '', line 21, position 16.\r\n"

Sample JSON Payload

  "isEnabled": true,
  "isBlocking": false,
  "settings": {
    "minimumApproverCount": 1,
    "creatorVoteCounts": false,
    "scope": [
        "repositoryId": "50350e0b-fdbb-471a-8e26-53faefc14ecb",
        "refName": "refs/heads/master",
        "matchKind": "exact"
    "buildDefinitionId": 1,  // Replace with your build definition ID
       "isCommentResolutionEnabled": false,
       "isResetOnSourcePush": false
  "type": {
       "id": "3"  // Replace with the actual ID of the policy type
   "revision": 1

I should be creating this via API, where as the creation through Azure CLI works fine.

I have tried to list the Azure policy types using API<orgid>/<projectid>/_apis/policy/configurations?api-version=7.0&scope=<repositoryid>&$top=1000 but I get the error

Error Response

{"$id":"1","innerException":null,"message":"Pagination is not supported for this endpoint.","typeName":"System.ArgumentException, mscorlib","typeKey":"ArgumentException","errorCode":0,"eventId":0}

Could you please help me on this at the earliest.

Kind Regards,



Not Monitored
Not Monitored
Tag not monitored by Microsoft.
36,527 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 26,241 Reputation points Microsoft Employee

    Hi @Renjini Kamala

    Questions related to Azure DevOps aren't really monitored on this forum. DevOps has its own separate community forum that has better engagement.

    Having said that, when I looked up Configure polices and the examples, its showing type set to a GUID. That's more than likely your issue, the POST is expecting a GUID and you're passing an int. The unfortunate thing is that I don't know if can be set to any GUID or if it has to be a GUID defined in DevOps account.

    0 comments No comments