How to fetch the keys of response body in test script

You can use Object.keys like this:

const response = pm.response.json();
const keys = Object.keys(response);
console.log(keys);

JavaScript Documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys

3 Likes