0
votes

I am POSTing valid JSON to a logic app and the request body is a simple set of name/value pairs in JSON format. I use parse JSON action to turn the JSON into a variable. (I am not sure if this is absolutely required, or if I can reference the http body directly without a JSON object).

[
  {
    "name": "fullname",
    "value": "joe schmoe"
  },
  {
    "name": "email",
    "value": "[email protected]"
  }
]

All I need to do (and this is driving me nuts) is create two variables, one containing the value of the email field and one containing the value of the fullname field. As soon as I try to use the output value value, the logic app replaces my action with a For Each action, and then I try to to assign item().value[0] or item().value[1] to a variable without luck.

I have read dozens of examples online, but of course they all seem to be parsing JSON where there is largely unique elements in the name:value pairs.

While this is a bit of a newb question, I'm confused and need advice. Thank you.

1

1 Answers

0
votes

I used a parseJSON action to ensure I have a varaible containing the JSON array. I then referenced the array value with (explained):

"from the body of the output from the Parse JSON action, refernce the first record in the set (fullname) and then the value of that record, the value 'joe schmoe'"

@{body('Parse_JSON')[0]['value']} (returns fullname)

Email is similar, just 2nd record in the collection: @{body('Parse_JSON')[1]['value']} (returns email address)