1

I have an endpoint from where I can download an xlsx file. My end goal is to validate the contents of the file. Is it possible to do it in karate by casting the response and then matching the values without writing it to a excel as mentioned in this question How to get the downloaded xlsx file from the api endpoint in karate?. Currently when I try to cast it to a string, it's printing junk values. My code is as below:

 Given url url1
 When method POST
 Then status 200
And match header Content-disposition contains 'attachment'
And match header Content-disposition contains 'example.xlsx'
And match header Content-Type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
* string response = responseBytes
* print response
darklord84
  • 47
  • 3

1 Answers1

0

You will see junk values, because it is binary content, and not plain-text.

Karate does NOT support the Excel binary format natively. You may be able to find a Java library to "read" the downloaded file, but that's not within the scope of Karate.

Also see: https://stackoverflow.com/a/49768421/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248