Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access response size in postman test

Tags:

postman

Is it possible to access the value of the response size in my postman test cases ?

While I am able to see the response size alongside the status code and the response time (both of which i can use in my test cases using responseCode.code and responseTime) I have not been able to use it in my tests. [I tried variables like responseSize and so forth to no success]

like image 695
Karan Shishoo Avatar asked Aug 17 '17 18:08

Karan Shishoo


2 Answers

pm.response.responseSize will give you the response size of the body.

like image 170
Sbaddam Avatar answered Oct 23 '22 16:10

Sbaddam


Adding an example to Sbaddam's excellent answer:

pm.test("response size", function () {
    pm.expect(pm.response.responseSize).to.be.equal(1252184);
});
like image 34
TheRealZing Avatar answered Oct 23 '22 15:10

TheRealZing