10-31-2023 11:43 AM
Hello all,
I have a HTTP Client snap that returns a file as response (it's a legacy Word .doc file), and I can't seem to be able to save it correctly as binary file.
The results returned by the call is actually the binary content of the file. When I used Python or Postman to validate the response, saving the response directly in a file worked perfectly, I received a valid Word 97 .DOC document.
I'm facing some issues with SnapLogic, although I can see that the response from the HTTP call is correct:
The value of the key "entity" is actually what I want to save directly as binary file.
I then use a mapper to get only the value that I need:
Then I convert the document to binary:
And I use the file writer to generate the document:
The document that I generate is unfurtunately not valid.
Is there a way to save binary documents when they come directly as a response from an HTTP call?
Thanks in advance!
JF
Solved! Go to Solution.
10-31-2023 12:27 PM
@jfpelletier - I tested a similar use case, downloading a sample PDF from https://www.africau.edu/images/default/sample.pdf using the HTTP Client snap, using GET request method. Note that by changing the output view type to Binary in the HTTP Client snap "Views" tab, you can go directly to the File Writer and you get a valid output file.
Hope this helps!
10-31-2023 12:27 PM
@jfpelletier - I tested a similar use case, downloading a sample PDF from https://www.africau.edu/images/default/sample.pdf using the HTTP Client snap, using GET request method. Note that by changing the output view type to Binary in the HTTP Client snap "Views" tab, you can go directly to the File Writer and you get a valid output file.
Hope this helps!
10-31-2023 12:50 PM
Hello @koryknick,
Thanks for letting me know that we can output binary directly from the HTTP client, that's very good to know!
So I tried that and unfortunately my resulting document is still not valid. Maybe my issue is the way that I retrieve the file? When I look at the preview to download the results, it says that the file only contains the 20,000 first bytes, which is not the correct size. What is the best way to download a file that I downloaded from the HTTP client?
Kind regards,
JF
10-31-2023 01:08 PM
I forgot to attach the screenshot of the results that I mentioned earlier:
11-01-2023 09:17 AM
Hello again @koryknick,
I think that I found the root cause of my issue. I was trying to download the results from the Preview in the snap, so I was probably just getting a partial file. When I go to the Manager I can see the whole file, and when I download it from there, I'm getting a valid Word document!
Thanks a lot for your help and advices, I think we can close this ticket now.
Kind regards,
JF