简体   繁体   中英

Azure logic apps http connector does not parse json in queries

    {
      "Query": {
        "inputs": {
          "headers": {
            "Content-Type": "application/json"
          },
          "method": "GET",
          "queries": {
            "f": "json",
            "temp": "\"test\": @json(body('http'))['candidates'][0]['location']['x']"
          },
          "uri": "https://testurl.com/restApi"
        },
        "runAfter": {

        },
        "type": "Http"
      }
    }

It reads "temp" as "test" : @json(body('http'))['candidates'][0]['location']['x']"

If I change this line to

    "temp": "@json(body('http'))['candidates'][0]['location']['x']"

It read the correct value from json. Not sure if its a bug, or I am missing some syntax.

You may try what Steven answered ( https://stackoverflow.com/a/44062649/7997843 ) or this which is more explicit to me:

"temp": "@concat('\"test\":', json(body('http'))['candidates'][0]['location']['x'])"

I suggest you to read about string interpolation in the workflow definition language here: https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-definition-language#Expressions

Your case seems to be a limit case. Either you begin your expression with @ ou @{ and then the name of your function or you can begin with a string but then you won't have any choice but to use @{

您可以尝试使用以下语法:

"temp": "\"test\": @{json(body('http'))['candidates'][0]['location']['x']}"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM