Avai
Avai

Reputation: 41

How to set and get JSON.parse(request.data) in global variable in postman?

Can anyone let me know how to set and get the 'request.data' into a global variable as I am intended to access the request body of a post request in a subsequent get request later?

I tried the below, but this is not working.

pm.globals.set("reqBody", JSON.parse(request.data));

pm.expect(response.name).to.equal(pm.globals.get(reqBody.pr_practice_name))

Upvotes: 3

Views: 908

Answers (1)

Avai
Avai

Reputation: 41

As Chris G replied above, the following resolved my issue:

pm.globals.get("reqBody").pr_practice_name

Upvotes: 1

Related Questions