cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Using REST GET to read zip output

Regina
New Contributor II

Hello All,

I have a requirement where I am getting a response from a REST GET as a ZIP file.
REST GET snap returns error when it tries to read ZIP output. Please see screenshots below. Can you please let me know what should be done to allow REST Get to process ZIP output? Any help to solve this issue would be highly appreciated.

Thank you!

Regina K.

image
image
image

1 ACCEPTED SOLUTION

tstack
Former Employee

The error is due to the REST snap trying to interpret the response as JSON. Youโ€™ll need to change the โ€˜Response entity typeโ€™ option to โ€˜BINARYโ€™ to get the snap to work. However, once that is done, youโ€™ll need to jump through a couple of hoops to get the zip unpacked. It turns out the ZipFileRead snap can only read from a file, so youโ€™ll need to write out the binary from the REST snap. To write out the binary data, you can use a DocumentToBinary snap to turn the document into a binary document and then a FileWriter that writes to the pipeline temporary directory. Finally, the ZipFileRead snap can read that file and you can do stuff after that.

08

Iโ€™m attaching the example pipeline as well:

RestGetZip_2019_02_05.slp (9.1 KB)

View solution in original post

2 REPLIES 2

tstack
Former Employee

The error is due to the REST snap trying to interpret the response as JSON. Youโ€™ll need to change the โ€˜Response entity typeโ€™ option to โ€˜BINARYโ€™ to get the snap to work. However, once that is done, youโ€™ll need to jump through a couple of hoops to get the zip unpacked. It turns out the ZipFileRead snap can only read from a file, so youโ€™ll need to write out the binary from the REST snap. To write out the binary data, you can use a DocumentToBinary snap to turn the document into a binary document and then a FileWriter that writes to the pipeline temporary directory. Finally, the ZipFileRead snap can read that file and you can do stuff after that.

08

Iโ€™m attaching the example pipeline as well:

RestGetZip_2019_02_05.slp (9.1 KB)

Regina
New Contributor II

Thank you for detailed info. It helped a lot! Regina