How to validate an environment variable in a response of get request

I have set an environment variable from a response of Post request and variable has set well. now I want to verify whether that value is saved in database by pulling the data using Get request.
I used below code under tests of the Get request.
tests[“Body matches string”] = responseBody.has(promo);

but it is not able to get the promo and showing the below error message

“ReferenceError | promo is not defined”

Excuse me if I did not understand your question correctly, but you basically want to compare your variable from the POST against what is returned from the response? If that’s the case, assuming the response is json, you can do something like the following…

pm.test(“name of your test”, function () {
const jsonData = pm.response.json()

1 Like

Hi, thank you for the reply.
But my problem is in the pm.environment.get({{variable}}). Environment variable “promo” is not getting and showing error in test result.

When calling pm.environment.get({promo}) try quotation marks instead of the curly braces.



It works. Thank you.

1 Like

This worked! Thank you. Have been searching for this for awhile now, really appreciate your help here.