-2

How do I extract personReference from the json response in postman tool? I just wanted to extract the personReference & parameterized it in next level requests:

{
    "result": "https://hi.helloworld.com/UAT?personReference=CD6alG%2Fwl0CxX9ARraBexg%3D%3D&commMethodReference=C3%2BQqN7vBUhGbb8hytvSTA%3D%3D&
code=s6wodIXv7Pd5XPE4Sa7WzGT4BhZgi%2FL67hDQ7sfLG2A%3D",
}
İsmail Y.
  • 3,579
  • 5
  • 21
  • 29

1 Answers1

0

personReference is not part of the json response. It is simply part of the String value of result. Ideally you can set global variable by

var jsonData = JSON.parse(responseBody);
postman.setGlobalVariable("variable_key", jsonData.result);

It will set the whole value of result in Global Variable "variable_key". You can set it as environment variable by

postman.setEnvironmentVariable("variable_key", jsonData.result);\

For your special case you need to write few logic in Javascript like(I did not try this, if it does not work please refer to more robust ways here):

var url = new URL(result);
var c = url.searchParams.get("personReference ");
Supritam
  • 259
  • 1
  • 9