1

I have a scenario, where the response is a binary file. This response has multiple zip files and each zip file has one or more json files within. Can anyone suggest how to verify this response?. Thanks in advance.

I tried karate.write(response,"response.zip") to store the response in a zip file. Zip file is getting created but when i try to unzip it has only one zipped record(where as it should have had all the zip files available in response) which is in corrupted form or with 0kb.

Note: response header: Contenty-Type: application/octet-stream

advith
  • 11
  • 2

1 Answers1

0

Karate does not have support for ZIP files.

If you found only one zipped record maybe it is an actual bug.

I have 2 suggestions:

  1. Maybe if you just run some commands on the command-line, you can achieve what you want. Karate has good support for that: https://stackoverflow.com/a/62911366/143475

  2. Write a custom Java utility and integrate it: https://stackoverflow.com/a/62826394/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • Thank for reply Peter. When i tried the same scenario from postman i am getting multiple zipped files, so no issues there. I will try with java custom function. – advith Dec 07 '22 at 08:57
  • @advith then clearly the way you are making your request in karate is not what your server is expecting. try opening the file you got as a text file, it might be some error page – Peter Thomas Dec 07 '22 at 10:18
  • request which i passed and the response which is displaying is correct in Karate as well. Below is how the actual response and the Karate print response also displays the same. (Here i have displayed the sample response, actual is bigger) PK[M�UMDI_TX_0.zipeVy8F�r.��Of� – advith Dec 09 '22 at 05:51
  • Content-type of this response is application/octet-stream. I want to pass this response to a java function, for that i want to know the type of this response. Could you suggest how i will know this? – advith Dec 09 '22 at 05:53
  • Its a get call with form-data of document id as request – advith Dec 09 '22 at 06:14
  • @advith karate does not have any special support for `application/octet-stream` which means binary files, please take the suggestion to write custom code seriously, or please assume karate does not support what you want – Peter Thomas Dec 09 '22 at 08:08