3

I need to use the same value into two different elements/attributes on the one XML request body. I tried to add it as a collectionVariable and recall it from there but Postman generates two different values for them.

For example, I am trying to generate $randomEmail dynamic variable and use it in two request body elements:

<Email>{{$randomEmail}}</Email>
<ConfirmEmail>{{$randomEmail}}</ConfirmEmail>

When I check the sent request then I can see that Postman actually sent different values for mentioned elements like:

<Email>test1@email.com</Email>
<ConfirmEmail>test2@email.com</ConfirmEmail>

Do you have any idea how to define one specific value per each request and use it on several body elements/attributes?

1 Answers1

4

store the value in a variable using prerequest script:

 pm.variables.set("email",pm.variables.replaceIn("{{$randomEmail}}") )

now in the body use it like :

 <Email>{{email}}</Email>
 <ConfirmEmail>{{email}}</ConfirmEmail>
PDHide
  • 18,113
  • 2
  • 31
  • 46