5

Can I use environment variables set in a previous test in the payload I am posting?

eg.

POST /list { "some_key": environment.saved_value } 

1 Answer 1

11

Yes, you can do that. You send it up like this

{ "some_key" : "{{environment_variable_name}}" } 

So, if in your previous test you had set it with something like

postman.setEnvironmentVariable("id","some_value") 

You can use it in your POST with

{ "some_key" : "{{id}}" } 

Hopefully, that answers your question

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

3 Comments

this does not seem to work with boolean values, I tried { "val" : "{{myval}}" } where myval in the environmnent is true yet when the put hits the server it comes through as false
also this does not work when submitting a request through newman
it seems it does not work with string types through newman, but numeric types are fine

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.