8

I have a HTTP listener that I am sending a JSON post body with.

{
"recipient":"[email protected]",
"subject":"this is a test subject",
"body":"this is a test body email"
}

I am trying to pull those individual parameters out in the next flow, but it errors instead!

The result I am looking to achieve is "[email protected]" being taken as an input for the next action

I've tried things like

"@{triggers().outputs.body.Content.recipient}"

and various variations of, but I suspect I'm missing something!

edit to add

I am currently sending the post request via Powershell, though it will ultimately be over c#

$a = @"
{"recipient":"[email protected]","subject":"this is a test subject","body":"this is a test body email"}
"@

Invoke-WebRequest -Uri     https://httplistenerc743421edf234899a1315aa38c6398bc.azurewebsites.net/listen -Method POST -Body $a
5
  • 1
    How are you sending the JSON POST? Commented Sep 3, 2015 at 16:30
  • 1
    @ShaunLuttin via Powershell - see edit Commented Sep 3, 2015 at 16:51
  • Did you use basically this process to setup the listener? azure.microsoft.com/en-us/documentation/articles/… I want to ensure I am answering the right question. Commented Sep 3, 2015 at 16:57
  • 1
    Yes, the listener works fine, if I just put "@{triggers().outputs.body.Content}" then it will forward the entire JSON wherever I want it to (I'm testing it in a slack connector) but I want to deserialize the JSON into its components Commented Sep 3, 2015 at 17:04
  • @ShaunLuttin Much appreciated - and note to self, delete that listener now I've posted it to the universe ;) Commented Sep 3, 2015 at 17:10

3 Answers 3

13

Ah the trick with this is the output of the HTTP Listener body is a String, so you need to convert it to JSON before you can parse it. There is a @parse() command to do just this.

So if you do this it should work:

@{json(trigger().outputs.body.Content).recipient}

That should give you the recipient. Let me know if that doesn't work.

Sign up to request clarification or add additional context in comments.

3 Comments

that works perfectly! thank you - On a related note, I'm wondering if it is worth a question about how to discover these things (or if it just comes from someone who programs these things rather than hacks about with them like I do!)
It's a good question. The syntax docs can be found here but we are working hard to make sure that's easier to find. Always welcome to reach out to me directly as well if you have any questions (or feedback, we love that too :). jehollan[at]microsoft.com
Just an FYI,@parse is now deprecated. Use @json instead.
2

You have to define content-type in header of http listener, after which you don't need to parse http listener's response, it will automatically in described format.

Comments

1

as i did with mine where azure function is returning json data as text/string:

@{body('azure_fun_Name').recipient}
@{body('azure_fun_Name').subject}
@{body('azure_fun_Name').body}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.