0

[
    {
        "Value": "987654",
        "Type": "EF"
    },
    {
        "Value": "987159",
        "Type": "DE"
    },
    {
        "Value": "987789",
        "Type": "CD"
    },
    {
        "Value": "987456",
        "Type": "BC"
    },
    {
        "Value": "987123",
        "Type": "AB"
    }
]

I WANT to fetch Value on the basis of Type, and save it to Environment variable, if Type= CD, Value set to environment variable CDValue=987789

1 Answer 1

1

You can do this.

In tab Test in Postman:

const res = pm.response.json();
res.forEach((e) => {
    pm.environment.set(e.Type + "Value", e.Value);
})

Result:

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks @lucasnguyen17, it's working...
@GavendraSingh Please accept it as a correct answer and upvote

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.