VSTS Rest API从Azure逻辑应用程序失败,但从Postman成功 [英] VSTS Rest API fails from Azure logic app but succeeds from Postman

查看:93
本文介绍了VSTS Rest API从Azure逻辑应用程序失败,但从Postman成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have an Azure logic app that uses a "Send HTTP request" block to send a REST API call to VSTS to create an incident. The call fails with "HTTP Error 400. The request hostname is invalid.".

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

I tried the same request from Postman and the request succeeded. To make sure that I am making the same request I copied the URI, the headers, the body from the logic app.

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

How can I further investigate what is going on? Is there a log in VSTS where I can find out more info. Any help, any suggestion is highly appreciated.

这里有"HTTP请求块"的代码

Here you have the code of the "HTTP request block"

{
"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]"
}

}

这是请求块的屏幕截图:

Here you have a screenshot of the request block:

推荐答案

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

We could easily do that with Azure Logic App - Azure DevOps connector.

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

I do a demo for creating an Azure DevOps workitem.

以下是详细步骤:

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

1.Create a logic App and send an http request to Azure DevOps action

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

2.Connect to Azure Devops and add the related information, for information please refer to the screenshot.

  1. 在我这边进行测试

这篇关于VSTS Rest API从Azure逻辑应用程序失败,但从Postman成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆