0

PostMan supports faker-library and provides several variables like "randomFirstName" and so on. However, I try to make them work in a pre-request script.

I've found a blogpost about this topic telling that it actually should work:

pm.variables.replaceIn("{{$randomProductName}}")

However, for me it doesn't work. The variable won't be replaced:

var firstName = "{{$randomFirstName}}"

console.log(firstName)

The output is:

{{$randomFirstName}}

How can I use these variables in a pre-request-script in PostMan?

itinance
  • 11,711
  • 7
  • 58
  • 98

1 Answers1

5

You can't use the {{}} syntax in the pre-request and test tabs.

The following will do:

var firstName = pm.variables.replaceIn("{{$randomFirstName}}");
Christian Baumann
  • 3,188
  • 3
  • 20
  • 37