My question:
To automate Name generation in Test requests, I want to use a random collection variable in the collection pre-request script.
Problem is that I don’t see the actual value in the variable, request body → some kind of Typo?
Details (like screenshots):
I use the following pre-request script function to set the Collection variable
function randomString(length=1) {
let randomString = "Test_";
for (let i = 0; i < length; i++){
randomString += pm.variables.replaceIn("{{$randomAlphaNumeric}}");
}
return randomString;
}
STRING_LEN = 15
pm.collectionVariables.set('CollRandomString', randomString(STRING_LEN));
The variable is correctly set:
But when I want to use this variable in a request body, the current value is not shown during mouse-over.
{
"$type": "bla",
"Message": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<functionname>
<functionparameter>
<Name>{{CollRandomString}}</Name>