Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
163 views
in Technique[技术] by (71.8m points)

VSTS Rest API fails from Azure logic app but succeeds from Postman

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.".

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.

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.

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": "[
    {
    "op": "add",
    "path": "/fields/System.Description",
    "from": null,
    "value": "@{body('Parse_JSON_2')['Description']}"
  },
  {
    "op": "add",
    "path": "/fields/System.Title",
    "from": null,
    "value": "@{body('Parse_JSON_2')['Title']}"
  },
  {
    "op": "add",
    "path": "/fields/System.IterationPath",
    "from": null,
    "value": "<your-iteration-path>"
  },
  {
    "op": "add",
    "path": "/fields/System.AreaPath",
    "from": null,
    "value": "<your-area-path>"
  },
  {
    "op": "add",
    "path": "/fields/Microsoft.VSTS.Common.Priority",
    "from": null,
    "value": "2"
  },
  {
    "op": "add",
    "path": "/fields/Microsoft.VSTS.Common.Severity",
    "from": null,
    "value": "2 - High"
  },
  {
    "op": "add",
    "path": "/fields/Microsoft.VSTS.CMMI.HowFound",
    "from": null,
    "value": "Azure Monitoring Alert"
  },
]"
}

}

Here you have a screenshot of the request block:

enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

I do a demo for creating an Azure DevOps workitem.

The following is the detail steps:

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

enter image description here

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

enter image description here

  1. Test it on my side

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...