How to receive a JSON message and form-data with a file attachment in Logic Apps?

Shiva Sadayan 61 Reputation points
2025-01-28T13:22:22.0366667+00:00

I'm new to Logic Apps, and I need to handle a message body with the following JSON format:

{
  "transactionid": "12345",
  "transactiondate": "2025-01-01",
  "customerId": "CUST001",
  "branch": "Branch001"
}

Additionally, I need to receive form-data that includes a file attachment, specifically a .csv file.

Is it possible to receive both the JSON payload and the file in a Logic App and upload the file into a storage account?

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,542 questions
{count} votes

Accepted answer
  1. Loknathsatyasaivarma Mahali 2,740 Reputation points Microsoft External Staff Moderator
    2025-01-28T14:12:15.46+00:00

    Hello @Shiva Sadayan,

    Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.

    Yes, it is possible to receive both a JSON payload and a file attachment in Azure Logic Apps. You can achieve this by using a combination of HTTP triggers and actions.

    • First set up an HTTP trigger in your Logic App that listens for incoming requests containing JSON. The JSON payload you provided can be processed using the built-in functions of Logic Apps.
    • To handle form-data that includes a file attachment, you can specify the content type as multipart/form-data. In the HTTP request body, you can include a JSON object that specifies the $content-type and $multipart attributes, allowing you to handle the file upload alongside the JSON data.
    • After receiving the file attachment, you can use the Azure Blob Storage connector to upload the file to your storage account and you will need to specify the blob name and content in the action that creates the blob.

    Here’s a brief example of how the HTTP request body might look for receiving both JSON and file data:

    {
      "$content-type": "multipart/form-data",
      "$multipart": [
        {
          "body": "{\"transactionid\":\"12345\",\"transactiondate\":\"2025-01-01\",\"customerId\":\"CUST001\",\"branch\":\"Branch001\"}",
          "headers": {
            "Content-Disposition": "form-data; name=\"jsonPayload\""
          }
        },
        {
          "body": "<file-content>",
          "headers": {
            "Content-Disposition": "form-data; name=\"file\"; filename=\"attachment.csv\""
          }
        }
      ]
    }
    

    You can then process the JSON data and upload the file to your storage account using the appropriate actions in your Logic App.

    Also, for your better understanding please refer the document to Add an action to create a blob for email body and to know Content with multipart/form-data type.

    I hope the above provided information helps in understanding better and solve your issue, if you have any further queries or concerns, please feel free to reach out to us.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.