CSV File upload in Logic Apps using multipart/form-data

Pratik Sharma 0 Reputation points
2024-01-08T16:15:14.88+00:00

I have an external rest api which accept two parameters, one parameter is .csv file and another one is string value (text). Below How I implemented in HTTP connector, code view is pasted below.

image

Any idea will be greatly appreciated, how to fix the issue.

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

2 answers

Sort by: Most helpful
  1. MikeUrnun 9,777 Reputation points Moderator
    2024-01-10T07:52:52.23+00:00

    Hi @Pratik Sharma - Thanks for providing the above. Just to double-check, is the URL of the API that you're calling the following? (works on Postman but not via Logic Apps?)User's image

    If so, it looks like a hostname pointing to a server running on your local network so when Logic Apps attempts to call the same URL via its HTTP connector, it's not able to resolve the hostname on the internet.
    UPDATE:
    When constructing multipart request using the HTTP connector, you'll want to describe the request using JSON as shown below:

    {
      "$content-type": "multipart/form-data",
      "$multipart": [
        {
          "body": "contents of a file 1",
          "headers": {
            "Content-Disposition": "form-data; name=\"file1\"; filename=\"file1_name.txt\"",
            "Content-type":"text/plain"
          }
        },
        {
          "body": "contents of a file 2",
          "headers": {
            "Content-Disposition": "form-data; name=\"file2\"; filename=\"file2_name.txt\"",
            "Content-type":"text/plain"
          }
        }
      ]
    }
    

    and add it in the Body field of the Connector as shown here: User's image

    For more info, here's the doc on the matter: Content with multipart/form-data type


    Please "Accept Answer" if the answer is helpful so that others in the community may benefit from your experience.

    1 person found this answer helpful.
    0 comments No comments

  2. Antonio Freitas 0 Reputation points
    2024-01-10T14:05:49.5366667+00:00

    I believe you want to create a multipart form data .

    Check this if it helps : https://medium.com/version-1/azure-logic-apps-how-to-post-multipart-and-form-data-dbc2e8640c67

    Check if correct "Content-Type" header, if it works in postman check what header in console and replicate in Logic App Request.

    Regards AF


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.