How to get REST response size in Karate?

Viewed 485

In Karate framework using Visual studio, I am making a REST call. I need to get the response size in KB or MB.

I tried these:

    • print response.size

Response: [jdk.dynalink.beans.SimpleDynamicMethod int java.util.HashMap.size()]

    • print response.length

Response: 6 This is the # of nodes of the response (items,hasMore,count,limit,offset,links)

    • print responseHeaders

Response: This gives me the response headers. It does not have response size

Can someone suggest a way to get the response size?

1 Answers

The responseBytes will contain the raw bytes and you can get the JavaScript length property like this:

* print 'size:', responseBytes.length

Note that I am using Karate version 1.X

Related