【发布时间】:2021-10-30 00:57:27
【问题描述】:
我正在尝试禁用并重新启用使用 Azure DevOps REST API 为分支创建的分支策略。
使用CURL 我能够获得已在存储库中创建的分支策略列表。
curl --url "https://dev.azure.com/{ORG}/{PROJ}/_apis/policy/configurations?api-version=6.0" --user "username:password" --request GET --header "Accept: application/json"
输出:
{
"count":1,
"value":[
{
"createdBy":{
"displayName":"Akshay B",
"url":"XXXX",
"_links":{
"avatar":{
"href":"XXXX"
}
},
"id":"XXXX-XXXX-XXXX-XXXX-e0fdec2c1636",
"uniqueName":"XXXX@XXXX.com",
"imageUrl":"XXXX",
"descriptor":"XXXX"
},
"createdDate":"2021-08-30T12:24:43.0238821Z",
"isEnabled":true,
"isBlocking":true,
"isDeleted":false,
"settings":{
"minimumApproverCount":2,
"creatorVoteCounts":false,
"allowDownvotes":false,
"resetOnSourcePush":false,
"requireVoteOnLastIteration":false,
"resetRejectionsOnSourcePush":false,
"blockLastPusherVote":false,
"scope":[
{
"refName":"refs/heads/master",
"matchKind":"Exact",
"repositoryId":"XXXX-XXXX-XXXX-XXXX-cd2a5c3167b3"
}
]
},
"isEnterpriseManaged":false,
"_links":{
"self":{
"href":"XXXX"
},
"policyType":{
"href":"XXXX"
}
},
"revision":1,
"id":2,
"url":"XXXX",
"type":{
"id":"XXXX-XXXX-XXXX-XXXX-4906e5d171dd",
"url":"XXXX",
"displayName":"Minimum number of reviewers"
}
}
]
}
现在我正在尝试使用以下CURL 命令禁用上面创建的策略:
curl --url "https://dev.azure.com/{ORG}/{PROJ}/_apis/policy/configurations/2?api-version=6.0" --user "username:password" --request PUT --header "Content-Type: application/json" --data '{\"isEnabled\":false}'
但我最终得到了错误:
{"$id":"1","innerException":null,"message":"TF400898: An Internal Error Occurred. Activity Id: xxxx-xxxx-xxxx-xxxx-70e5364888b7.","typeName":"Newtonsoft.Json.JsonReaderException, Newtonsoft.Json","typeKey":"JsonReaderException","errorCode":0,"eventId":0}
在要为PUT 方法传递的 JSON 数据中是否遗漏了什么?
【问题讨论】:
标签: azure azure-devops azure-devops-rest-api azure-repos