Search code examples
jsonazurerestazure-logic-apps

Read message from sevice bus - send to a web api


What I want to do is to read a json message from at Service Bus queue, and then call a REST API with that json message. Exact same format, no need for mapping.

What I have done so far is created a Azure Logic App with a Service Bus trigger.

I call the API with the body of the message.

I get a HTTP 400 Bad Request response with a list of fields that are missing.

The request from the Logic app sends the json doc base64 encoded in the ContentData field, "ContentTransferEncoding": "Base64"

The Content type in the header is application/json.

If I decode the string and post that json using Postman, it works fine.

Any Ideas?


Solution

  • To resolve this issue, make use of the base64ToString function to decode base64-encoded ContentData.

    E.g. instead of

    @items('For_each')?['ContentData']
    

    send

    @base64ToString(items('For_each')?['ContentData'])
    

    in the body of your HTTP request.

    Adapt this solution based on your Logic App code.