0

I have an Azure Logic App with a queue trigger. The queue message is JSON. When I send "Message text" to an Azure function, I get

UnsupportedMediaType
{
  "Message": "The WebHook request must contain an entity body formatted as JSON."
}

I'd assumed this would work directly.I tried setting request body to

@{json(<Message text>)} 

where is the select dynamic content item, but I get red message "Enter a valid json".

What's the trick to making this connection? Do I have to pass in and then parse out "Message text" in my function? Again, I assumed it would do that automagically.

4
  • Also, why are there two dynamic elements named "Body" coming from the message queue trigger? Commented Mar 23, 2017 at 17:46
  • Can you confirm that they are both coming from the trigger? You would see one for any preceding action as well. It could also be the case that there is a property named 'body' in the content, hence the designer would show one token for message content as w whole, and one for the property named 'body'. Which specific queue trigger are you using? Commented Mar 24, 2017 at 2:19
  • I have a "when there are messages in the queue" trigger. Immediately after I have a Function action. The dynamic content list has two "Body" entries. shufflepoint-media.s3.amazonaws.com/double_body.png Commented Mar 25, 2017 at 3:36
  • I ended up passing the body into my function, and then parsing the "message text". That works, but like I said, I would have assumed that I could pass in "message text" directly. Commented Mar 25, 2017 at 3:39

2 Answers 2

1

The @{} syntax indicates string interpolation. This means that your expression @{json(<Message text>)} de-serializes the message text to json, and then serializes it again.

Hence the expression that you want to use is

@json(<Message text>) 
Sign up to request clarification or add additional context in comments.

Comments

0

For future readers.

I was passing some (what seems to be to be valid) json to my webhook.

And kept getting the

"Message": "The WebHook request must contain an entity body formatted as JSON."

error.

:(

Finally, I found a json "expression" that did its voodoo and got rid of the error. I argument from the json-expression was my previous action's output, which was valid json. It apparently needs just a little help!

enter image description here

The raw (non designer) code was:

        "GenericWebHookCsharpOne": {
          "type": "Function",
          "inputs": {
            "body": "@json( body('MyPreviousAppLogicActionWhichIsAnAzureFunction'))",
            "method": "POST",
            "function": {
              "id": "/xxxxxxxxxxxxxxxxxxxxxxxx
            }

1 Comment

I know this is kinda like Szymon's answer. So I'm not trying to take away from his. Just adding for everyone mutual benefit.

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.