I would like to create a dynamic variable - a random 10-digit number
how do i do this?
Hi,
A simple way to do it, is to use the built-in library lodash.
e.g.
const randomNumber = _.random(1000000000,9999999999)
If you need to use it in a request, you can add this to a pre-request script like this:
const randomNumber = _.random(1000000000,9999999999)
pm.variables.set(‘randomNumber’, randomNumber )
then in the request body, add {{randomNumber}}
e.g.
{
"username": "Test",
" number": "{{randomNumber}}"
}
I hope this helps.
2 Likes
amazing
thank you very much!!
Your question may already have an answer on the community forum. Please search for related topics, and then read through the guidelines before creating a new topic.
Here’s an outline with best practices for making your inquiry.
My question:
Details (like screenshots):
How I found the problem:
I’ve already tried: