Sandeep Negi
Sandeep Negi

Reputation: 27

Access complete response size in postman test?

Is it possible to access the complete response size in postman with response body and headers ?

I am able to use the below method to get the size of the response body only

pm.response.responseSize

it will return the size in bytes.

My test case in postman to get the response size looks like this.

pm.test("verify the response size of body", function() {
   pm.expect(pm.response.responseSize).to.be.equal(1024);
  
} );

Thank you in advance , if it is possible to get the size of complete response size from postman , since my API gateway does not support size of the response to be greater than 10MB and I am returning the encoded attachments in response, so I need to verify that the size of response does not cross the upperbound.

Upvotes: 0

Views: 2261

Answers (2)

Jithin Jose
Jithin Jose

Reputation: 11

let responseSize=pm.response.size();
pm.test("Verify total response size",()=>{
    pm.expect(Number(responseSize.total)).to.be.below(1800);
    pm.expect(Number(responseSize.body)).to.be.below(1024);
    pm.expect(Number(responseSize.header)).to.be.below(800);
    }
);

Response contains body and header.For total response size use .total, for body size use .body & for header use .header

Upvotes: 1

PDHide
PDHide

Reputation: 19989

console.log(pm.request.size())
console.log(pm.response.size())

this gives you the computed size of request and response

Upvotes: 3

Related Questions