How to get the downloaded xlsx file from the api endpoint in karate?

In Karate 0.9.X onwards you have a responseBytes variable which will be raw bytes, which may be what you need.

* def value = FileChecker.createExcelFile(responseBytes)

And you can change your method signature to be:

public static String createExcelFile(byte[] excel) {}

You should be easily able to convert a byte array to an InputStream and take it from there.

P.S. just saying that it “works in Postman” is not helpful 😛

Leave a Comment