Extract value from response

I am trying to extract the value from json response to a variable and use it different api call.
I am always getting response as {equipmentId: 35001565}
I need only 35001565 in my variable.

I am new to postman and started using a week back, tried looking for solution and most of the results are about arrays, so posting a new thread here

Welcome to the community @ereddy068!

Are you familiar with JSON at all? That’s going to make your Postman life significantly easier.

If you add this script into the Tests tab, it will add the equipmentId as a collection variable:

const jsonData = pm.response.json();
pm.collectionVariables.set('equipmentId', jsonData.equipmentId);

Then in any request you need to use that on, you can just use {{equipmentId}} to reference it.

Thank you allen.

I was in a belief that postman will give autosuggestion of values if we give . at the end of jsondata.
Now I understood the process.

1 Like