Dynamic values
Getting started
In an endpoint, switch to the "Run" tab.
For the parameter you want to dynamize, delete the original value, then click the magic wand icon to the right of the value. In this example, I'll select the 
name
parameter.Click on "Data generator", and choose the dynamic value type you need, such as 
Person.firstName
.Click "Insert" to insert the dynamic value into the parameter.
Click "Send". You can see in the "Actual request" that the actual name sent is "Jennifer".
Send the request again, and a new firstname will be generated dynamically.
Using dynamic values in JSON body
Find a POST endpoint with a JSON body, and switch to the "Run" tab.
In the JSON body, click "Generate automatically - Generate field names", and you will get the property names defined in the spec.
Position the cursor in the correct place, click " Insert dynamic value", and select "Data Generator".
Choose the appropriate data type and click "Insert".
Add values for all the fields.
Click "Send". You can see the actual JSON body sent in the "Actual request" section.
If you send the request again, the dynamic values will generate a new JSON body.
Using dynamic values in Custom expression
Click on the dynamic expression to open the input box.
Generate expected content by inputting dynamic value expressions through methods such as concatenation. You can preview the generated information in real-time below.
Click on 'Insert'. You can see custom expressions in the parameter values section.
Desired Custom Content | Custom Expression | Example Return Value | Method Concatenation and Meaning |
---|---|---|---|
Random username with timestamp | {{$internet.userName}}_{{$date.now}} | "Kattie_Rice64_2024-09-04T05:51:42.413Z" | Use {{$internet.userName}} to generate a random username, use {{$date.now}} to get the current time, and concatenate them using template literals. |
Random email address with company domain | {{person.lastName}}@{{$company.name | lower}}.com | "Kole.Haag@schmidt-schoen.com" | Use {{$person.firstName}} , {{$person.lastName}} to generate a random name, use {{$company.name | lower}} to generate a company name, convert it to lowercase, and concatenate them to form an email address. |
Random address with street number and apartment number | {{$location.buildingNumber}} {{$location.street}}, Apt. {{$number.int(min=1,max=1000)}}, {{$location.city}}, {{$location.state(abbreviated=true)}} {{$location.zipCode}} | "723 Klein Inlet, Apt. 814, North Myron, DE 67605" | Use multiple methods to generate a detailed address, including street number, street name, apartment number, city, state, and zip code. |
Random company name with industry and company type | {{$company.buzzAdjective}} {{$company.buzzNoun}} {{$company.name}} | "web-enabled architectures Fay Inc" | Use the company method to generate a company name with industry description and company type. |
Random date within the past year | {{$date.past(years=1)}} | "2023-10-24T09:25:24.109Z" | Use the {{$date.past(years=1)}} method to generate a random date within the past year. |
Random price with currency symbol | {{$finance.currencySymbol}}{{$commerce.price}} | "KM12.89" | Use {{$finance.currencySymbol}} to generate a random currency symbol, use {{$commerce.price} to generate a random price, and concatenate them. |
Random product description | {{$commerce.productAdjective}} {{$commerce.productMaterial}} {{$commerce.product}} - {{$lorem.sentences(min=2,max=4)}} | "Small Wooden Pizza - Thema copiose dens adinventitias a. Causa uxor terreo defleo vitiosus animi. Ademptio possimus decet considero absorbeo sursum rem circumvenio antiquus curatio. Adipisci addo tredecim carbo." | Use {{$commerce.productAdjective}} and {{$lorem.sentences(min=2,max=4)}} methods to generate text containing product features and descriptions. |
Random sentence with hashtag | #{{$lorem.slug(min=1,max=3)}} {{$lorem.sentence(min=1,max=3)}} | "#provident-quidem-tempore Vita comprehendo id." | Use {{$lorem.slug(min=1,max=3)}} to generate a random hashtag and concatenate it before the sentence. |
Random IP address with port number | {{$internet.ipv4}}::{{$number.int(min=1024,max=65535)}} | "246.222.133.63::56332" | Use {{$internet.ipv4}} to generate a random IP address, use {{$number.int(min=1024,max=65535)}} to generate a port number, and concatenate them. |
Random URL with query parameters | {{$internet.url}}?{{$lorem.slug}}={{$lorem.word}} | "https://nippy-bob.name/?nemo-provident-clementia=blandior" | Use {{$internet.url}} , {{$lorem.slug}} , and {{$lorem.word}} to generate a random URL with query parameters. |
Random file path | /path/to/{{$lorem.slug}}/{{$system.fileName}} | "/path/to/caritas-solio-vilicus/across.img" | Use {{$lorem.slug}} , {{$system.fileName}} , and string concatenation to generate a random file path. |
Random database table name | table_{{$string.alphanumeric(length=5)|lower}} | "table_brxlr" | Use {{$string.alphanumeric(length=5)|lower}} to generate a random string and concatenate it to form a database table name. |
Random HTML code snippet | <p>{{$lorem.sentence}} <a href="{{$internet.url}}">{{$lorem.word}}</a></p> | " | Use {{$lorem.sentence}} and {{$internet.url}} to generate a random HTML code snippet containing a link. |
Random HTTP request header | { "User-Agent": {{$internet.userAgent}}, "Referer": {{$internet.url}} } | { "User-Agent": Opera/13.25 (Macintosh; Intel Mac OS X 10.7.9 U; HE Presto/2.9.171 Version/12.00), "Referer": https://queasy-dusk.info/ } | Use {{$internet.userAgent}} and {{$internet.url}} to generate a random HTTP request header containing User-Agent and Referer. |
Use cases for dynamic variables
Insert dynamic value manually
{{$
to trigger the dynamic variable list.$timestamp
.time
, and the system will automatically filter and display matching dynamic variables.Data generator
{{$date.now}}
, which can use the addDays
method to add days to generate data for a specific date.md5
function to encrypt a string and generate test data that meets security requirements.Setting the data Language/country
1.
2.
3.
format
and locale
methods.Powerful date operations and formatting
add
method, you can easily add or subtract time units based on the current time. For example, {{$date.now|addHours(-3)}}
will return the date 3 hours earlier than the current time.format
method, you can format dates into different formats as needed. For example, {{$date.now|formatISO}}
will format the date according to the ISO 8601 standard.timezone
parameter, you can easily control the time zone of the date. For example, {{$date.now|format('yyyy-MM-dd HH:mm:ss',timezone='America/Port-au-Prince')}}
will return the date corresponding to the current time in the UTC+8:00 time zone.Common dynamic variables
Modified atΒ 2024-09-06 07:57:07