Check property of JSON response in Postman

In the Tests section of any request you can check if the JSON response contains or doesn’t contain a specific property like this:

// Verify that header object is NOT returned
pm.test("Verify that header:{...} object is NOT returned", function () {
 pm.expect(pm.response.json()).to.not.have.property('header'); 
});

// Verify that data object is returned
pm.test("Verify that data:{...} object is returned", function () {
 pm.expect(pm.response.json()).to.have.property('data'); 
});

Easy as pie!

Leave a Comment

Your email address will not be published. Required fields are marked *