10-04-2019 03:39 AM
hi
we have a requirement to receive a file in snaplogic where we have to provide API URL to an external team. that team will do REST post along with file attached in POST request. we are supposed receive the file and store it. we tried a number of ways but it’s not working.
we sent a text file through Postman on API POST request as an attachment, but that pipeline failed with error msg as below.
“Document input views only accept JSON-encoded data”
let us know if there is a way to consume a file from such REST POST request with files attached to it
10-10-2019 07:54 AM
hey – originally I was thinking that you could just write to that constant file location with maybe a timestamp or uuid to make it unique. If you add an output view to the FileWriter, then it’ll respond to the request with the file locations of where things were written. Alternatively you could also use a regex to read the file names, or other parts of the content-disposition header, that are passed into your task and re-use those.
Here’s an example pipeline that shows how that second approach would work.
post-variable-filename-example_2019_10_10.slp (6.1 KB)
04-02-2024 12:28 AM
HI @tlikarish Above code isn't working for me. I tried to send .xlxs and .csv file but in mapper snap $['content-disposition'].match('filename=\"(.*)\"')[1] getting error that content-disposition not found
Appreciate your help on this issue
Anyone who know the solution can help us - appreciate your help
Thanks
04-03-2024 07:21 AM
Hi Rudhiran -- the double quotes were escaped in my example. Not sure where those came from, but could you try this expression, with backslashes removed, in your mapper and see if it will work for you?
$['content-disposition'].match('filename="(.*)"')[1]
04-03-2024 07:30 PM
HI @tlikarish ,
Multipart reader gives response only Content type and Content - Not the content-disposition
So we're getting error in mapper that