โ06-25-2019 07:50 AM
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?
โ06-28-2019 03:15 PM
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.
โ07-01-2019 07:15 AM
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.
โ07-01-2019 08:03 AM
In your response in SnapLogic, what http headers are you getting back?
Also, what http headers are you sending in postman request?
โ07-01-2019 08:17 AM
Here are my headers Iโm sending + getting back in Postman:
And here are my headers Iโm sending + getting back in SnapLogic: