Dhrumil
Dhrumil

Reputation: 117

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.

Upvotes: 0

Views: 524

Answers (2)

Julien B.
Julien B.

Reputation: 66

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://learn.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 @{

Upvotes: 3

Steven Van Eycken
Steven Van Eycken

Reputation: 566

Can you try with the following syntax:

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

Upvotes: 2

Related Questions