VSTS Rest API从Azure逻辑应用程序失败,但从Postman成功

时间:2019-01-07 18:58:04

标签: azure azure-devops azure-logic-apps azure-devops-rest-api

我有一个Azure逻辑应用程序,该应用程序使用“发送HTTP请求”块将REST API调用发送到VSTS来创建事件。调用失败,并显示“ HTTP错误400。请求主机名无效”。

我尝试了来自邮递员的相同请求,请求成功。为了确保发出相同的请求,我从逻辑应用程序复制了URI,标头和正文。

如何进一步调查正在发生的事情? VSTS中是否有日志,我可以在其中找到更多信息。任何帮助,任何建议都将受到高度赞赏。

这里有“ HTTP请求块”的代码

{
"inputs": {
    "method": "POST",
    "uri": "https://dev.azure.com/<your-vsts-organization>/<your-vsts-project>/_apis/wit/workitems/$Incident?api-version=4.1",
    "headers": {
        "Authorization": "Basic .................................",
        "Content-Type": "application/json-patch+json"
    },
    "body": "[\n    {\n    \"op\": \"add\",\n    \"path\": \"/fields/System.Description\",\n    \"from\": null,\n    \"value\": \"@{body('Parse_JSON_2')['Description']}\"\n  },\n  {\n    \"op\": \"add\",\n    \"path\": \"/fields/System.Title\",\n    \"from\": null,\n    \"value\": \"@{body('Parse_JSON_2')['Title']}\"\n  },\n  {\n    \"op\": \"add\",\n    \"path\": \"/fields/System.IterationPath\",\n    \"from\": null,\n    \"value\": \"<your-iteration-path>\"\n  },\n  {\n    \"op\": \"add\",\n    \"path\": \"/fields/System.AreaPath\",\n    \"from\": null,\n    \"value\": \"<your-area-path>\"\n  },\n  {\n    \"op\": \"add\",\n    \"path\": \"/fields/Microsoft.VSTS.Common.Priority\",\n    \"from\": null,\n    \"value\": \"2\"\n  },\n  {\n    \"op\": \"add\",\n    \"path\": \"/fields/Microsoft.VSTS.Common.Severity\",\n    \"from\": null,\n    \"value\": \"2 - High\"\n  },\n  {\n    \"op\": \"add\",\n    \"path\": \"/fields/Microsoft.VSTS.CMMI.HowFound\",\n    \"from\": null,\n    \"value\": \"Azure Monitoring Alert\"\n  },\n]"
}

}

这是请求块的屏幕截图:

enter image description here

1 个答案:

答案 0 :(得分:1)

我们可以使用Azure Logic App-Azure DevOps connector轻松地做到这一点。

我为创建Azure DevOps工作项进行了演示。

以下是详细步骤:

1。创建一个逻辑应用程序并将http请求发送到Azure DevOps操作

enter image description here

2。连接到Azure Devops并添加相关信息,有关信息,请参阅屏幕截图。

enter image description here

  1. 在我这边进行测试

enter image description here