REST Post Multipart Form-Data + File Upload Issue

I’m having trouble correctly formatting multipart form-data to be sent as the body of a REST Post request along with a single file upload.

I’ve managed to get the Post request to correctly send in Postman with the required key/value pairs and a test file:

However, when attempting to replicate this in SnapLogic I am unsuccessful.

I’ve managed to correctly map the key/value pairs in a mapper, and have created the following JSON in a JSON generator using my mapped values:


I’ve used my “entity” object as the HTTP entity in my Post request, and pointed to a local test file for upload in my REST Post snap:

Is my approach to compiling the form-data correct, or no?

Looks like you’re giving the entity JSON, a target server expecting form-data isn’t going to know what to do with that. Try formatting your entity like

‘key1=’ + $yourData1 + ‘&key2=’ + $yourdata2

Do it right in the entity setting of the snap.

Also, looks like your setting for Single File Upload: Multipart Content-Type is not set correctly. This field is for the MIME type of the file you’re trying to post, so when it gets formatted by the snap into a multipart request, it knows how to describe the file. So using “multipart/form-data” like you have set in the screenshot is not going to work.

It looks like you’re posting an xlsx file. So in your case you can either use the specific mime type for the file “application/vnd.openxmlformats-officedocument.spreadsheetml.sheet” or preferably the generic binary stream content type “application/octet-stream”. By doing that you let the target server know what kind of file you’re posting.

Try making those changes and see what your results are.

Thank you very much for the help and feedback, I’ve updated my pipeline with your requested changes.

The new HTTP entity is formatted as follows within the Post snap:


I’ve also changed the content type for the upload file to be “application/octet-stream”, and for the sake of testing am referencing the same file for upload in both Postman and SnapLogic. I’ve also set the file key to be the same as I’ve set it up in Postman:

I’m actually now getting a 200 back from the Post snap in SnapLogic, but the response back from my target endpoint is empty as compared to Postman.

Here’s the response back from SnapLogic:


And here’s the expected response as seen in Postman:


Based on your recommendations and from what I’ve shared, is my Post snap now setup correctly? At this point I feel like I’m overlooking some small detail. Any extra help is appreciated.

In your response in SnapLogic, what http headers are you getting back?

Also, what http headers are you sending in postman request?

Here are my headers I’m sending + getting back in Postman:

And here are my headers I’m sending + getting back in SnapLogic:



Could you expand that temporary headers section in postman in the request header section? What kind of authorization are you using in both postman and SL?

Also, have you checked the endpoint to see if the file from the SL post made it there regardless of the response body it’s giving back?

Here are my temporary headers in Postman:

To my knowledge there is no way to check if the file has been committed to the server, this call is the second call in a three-part upload process through the API. I can verify this if need be.

The first API call prepares the upload, the second API (this call) uploads the file to the server, and the third API call commits the uploaded file to the endpoint using values in the response body of this second API call.

If I had to guess I’d say it was the cookie. Postman is auto-sending this for you because it is stateful probably captured it in the return of your first API call.

In SnapLogic, each of the snaps execute separately, even if you have a chain of rest snaps they all function independently so you don’t have that luxury. You’d probably need to send the cookie which you’d probably get back in the header of your first call, and pass it as cookie header on calls 2/3.

Without sending the cookie for the second response I’d guess the server wouldn’t be able to tie it to the first rest op so it’s just giving you a blank response back.

1 Like

I passed the cookie into the request headers from my first API call with no luck, my response body is still empty from my Post request

I sincerely appreciate the help to date - at this point I’ve reached out to an administrator who wrote the endpoint API’s who can help clarify the formatting of the request for accuracy on their end.