Response value is same as in the request sent

I need to write automated test for the API response. The response contains values which are same as what I have sent as an request. I need to ensure that what I sent is been added in the database and reflected back in the response with an ID created. Please confirm if the below test is correct?
const json = pm.response.json();


let requestData= JSON.parse(;


pm.test(“Data Fields Test against request”,()=>{

Can you post an example request and response please? So we can check that they are exactly the same (which would be unusual).

Please use the preformatted text option in the editor when posting code or JSON, so it stops everything from being aligned to the left (and so we can cut and paste). Please don’t post as a screenshot.

In your code, you have…

let requestData= JSON.parse(;

Where is the “request” variable being set?

You have console logs for both variables, what is being shown there? That should be your first troubleshooting step.

You can parse the request body using the following, but please be aware that if you are using variables in your request body, then its not going to pull across the values and your assertion will fail.

const requestBody = JSON.parse(pm.request.body.raw);
const response = pm.response.json();


pm.test('Request body and response match', () => {

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.