Saving variable sent in json

Hi, So I’m trying to save a dynamic variable thats sent in the json on a post. Im using the faker.js library and sending my json like so
“email”: “{{email}}”,
“password”: “{{password}}”

This works fine up to this point, But I’ve been trying to save the result that email sends as a variable as I cannot fetch it in the json after it is sent, since that endpoint is only returning something like a GUID and an ID number but no email. I want to use this email in my further tests to login, but it seems I can only save the variable as {{email}} which gives me a new one each time.

Hi @cdolan90 ! I saw your note that you’ve figured out a solution. Do you mind sharing here what worked for you? I’m willing to bet that someone else may have a similar question down the line, and your solution can certainly help others :slight_smile:

Sure, so I just created a new variable with the data from the test as a pre-request script

var randomEmail = pm.collectionVariables.get("email");

postman.setEnvironmentVariable("testLoginEmail", randomEmail);

This grabs the email when it is sent in the request, puts it as an variable for future tests, just be sure to unset it with


:clap: :clap: :clap:

Glad you figured it out, and thanks for sharing!