Forum Discussion

jfpelletier's avatar
jfpelletier
Contributor
2 years ago
Solved

Writing output file from response from HTTP client

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

4 Replies

    • jfpelletier's avatar
      jfpelletier
      Contributor

      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

       

  • 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