Azure DevOps Server 2022环境审批REST API调用异常问题
Azure DevOps Server 2022调用审批记录API报错:需要至少一个查询参数
我尝试用Postman调用以下REST API列出审批记录:
GET https://{instance}/{collection}/{project}/_apis/pipelines/approvals?api-version=7.0-preview.1
该请求在Azure DevOps Services 7.1环境中能正常返回结果,但在Azure DevOps Server 2022实例中调用失败,收到的错误信息如下:
{
"$id": "1",
"innerException": null,
"message": "Query for approvals failed. A minimum of one query parameter is required.\r\nParameter name: queryParameters",
"typeName": "System.ArgumentException, mscorlib",
"typeKey": "ArgumentException",
"errorCode": 0,
"eventId": 0
}
原因分析
Azure DevOps Server 2022对该API的参数校验比Azure DevOps Services更严格,必须指定至少一个查询参数才能发起请求,而Services端允许无参数查询所有审批记录。
解决方法
你可以添加以下任意一种(或多种)查询参数满足API的要求:
statusFilter:按审批状态过滤,可选值如Pending、Approved、Rejected、CanceledassignmentFilter:按分配对象过滤,可选值如Me、AllpipelineId:按流水线ID精准过滤releaseId:按发布ID精准过滤
完整请求示例
查询当前用户待处理的审批记录:
GET https://{instance}/{collection}/{project}/_apis/pipelines/approvals?api-version=7.0-preview.1&assignmentFilter=Me
查询所有待审批状态的记录:
GET https://{instance}/{collection}/{project}/_apis/pipelines/approvals?api-version=7.0-preview.1&statusFilter=Pending
内容的提问来源于stack exchange,提问作者osim_ans
相关产品推荐
相关产品推荐

