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 'type.id', 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 https://dev.azure.com/<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,
Renjini.