2

Have dynamic generated post request for student pass every time send post method and want to use this dynamic_value in another request as an input. How to use this ?

{ "study pass":"dynamic_value"}

Used below but not storing that dynamic value in variable.

var Json=JSON.parse(responsebody); postman.setEnviormentVariable("study pass",jsonData.study_pass);

output (dynamic_value) from Request 1 > need to be used as input for Request 2

GPs
  • 67
  • 1
  • 10
  • study pass is temporary pass for student which needs to be updated by another request – GPs Jul 28 '20 at 16:56
  • Not exactly sure what you're asking here, what you're asking you seem to have already answered. Can you clarify some more? – so cal cheesehead Jul 28 '20 at 20:53
  • i want to use output value i.e. "dynamic_value" from Request 1 and input to Request 2. and with above by parsing json, but i am not getting that dynamic value in variable, so thats the issue – GPs Jul 29 '20 at 15:00
  • Does this answer your question? [Postman: Can i save JSON objects to environment variable so as to chain it for another request?](https://stackoverflow.com/questions/41479494/postman-can-i-save-json-objects-to-environment-variable-so-as-to-chain-it-for-a) – Henke Feb 10 '21 at 13:06

1 Answers1

0

Depending on where you want to use the environment variable study pass, you can use:

  • {{study pass}} in the URL, request body, request headers. form data
  • pm.environment.get('study pass') in the pre-request script or test

But you're setting a variable Json, but when calling setEnvironmentVariable, your using jsonData. With consistent naming, your problem should be fixed.

Christian Baumann
  • 3,188
  • 3
  • 20
  • 37
  • Variable showing null when used {{temp_token}} ```var tempvar = console.log(pm.response.json()["temp token"]); showing temp_token = JSON.stringify(tempvar); pm.environment.set("temp_token", temp_token); ``` – GPs Aug 10 '20 at 17:10