0
votes

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.

2
Also, why are there two dynamic elements named "Body" coming from the message queue trigger?Chris Harrington
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?Szymon Wylezol
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.pngChris Harrington
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.Chris Harrington

2 Answers

1
votes

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>) 
0
votes

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
            }