cancel
Showing results for 
Search instead for 
Did you mean: 

Writing output file from response from HTTP client

jfpelletier
Contributor

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:

jfpelletier_0-1698776333861.png

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:

jfpelletier_1-1698777121448.png

Then I convert the document to binary:

jfpelletier_2-1698777189970.png

And I use the file writer to generate the document:

jfpelletier_3-1698777777820.png

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

1 ACCEPTED SOLUTION

koryknick
Employee
Employee

@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.

koryknick_0-1698780396181.png

koryknick_1-1698780415559.png

koryknick_2-1698780433788.png

Hope this helps!

 

View solution in original post

4 REPLIES 4

koryknick
Employee
Employee

@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.

koryknick_0-1698780396181.png

koryknick_1-1698780415559.png

koryknick_2-1698780433788.png

Hope this helps!

 

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

 

I forgot to attach the screenshot of the results that I mentioned earlier:

jfpelletier_0-1698782890107.png

 

jfpelletier
Contributor

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