Logic Apps : How to get the display_value response from Http API cal

試著忘記壹切 提交于 2019-12-25 03:11:39

问题


In Azure Logic app, the response I am getting while I am making an Http response call is below.

{
 "import_set": "",
 "staging_table": "",
 "result": [
   {
    "transform_map": "",
    "table": "incident",
    "display_name": "",
    "display_value": "INC5164816461631654",
    "record_link": "",
    "status": "",
    "sys_id": ""
   }
 ]

}

How I can get the 'display_name' property. I tried several ways like

@triggers().outputs.body.result.display_name

@{body('HTTP')['result'][display_name]}

but it's not working.

Result: INC5164816461631654


回答1:


If your output is in json format, you could just get it with a expression:@body('HTTP')['result'][0]['display_name']. Cause under tag result it's array, so if you don't point the index, it won't be able to find the property.

And if your output is not json format, it will be a string. you need to parse it to json. Then you will be able to use same expression(@body('Parse_JSON')['result'][0]['display_name']) to get the value.




回答2:


Couple of ways to do this:

  1. If you are using directly from the response try this expression as below: directly on expression : triggerBody()?['result'][0]?['display_name'] or in Code view like this @triggerBody()?['result'][0]?['display_name'] the response should be a proper JSON.
  2. If it is not a proper json use Parse json with the payload schema and use the below expression : body('Parse_JSON')?['result'][0]?['display_name'] or in code view as @body('Parse_JSON')?['result'][0]?['display_name']. Note replace the parse_json with your corresponding shape name.
  3. By declaring Variables as mentioned by George but this would increase the flow, rather you can directly use the expression to extract the value.

Let me know if this helps! Cheers



来源:https://stackoverflow.com/questions/55927156/logic-apps-how-to-get-the-display-value-response-from-http-api-cal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!