How to generate 3 random data in response body

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:
How can we generate 3 different records in the response body of GET request ?

Details (like screenshots):

I’m trying to send a Get request using mock server. Lets say im sending /user/userdata Get request and i have added an example to this request and have set the status as 200 OK.
[{
“Id”: {{$randomInt}},
“CustomerId”: {{$randomInt}},
“FirstName”: {{$randomNamePrefix}},
“LastName”: {{$randomNameSuffix}},
“EmailID”: {{$randomEmail}},
“MobNumber”: {{$randomPhoneNumber}}
}]

I will get
[{
“Id”: 456,
“CustomerId”: 23,
“FirstName”: Max,
“LastName”: Black,
“EmailID”: Max.Black@123.com,
“MobNumber”: 12345789
}]

What should i do to get
[{
“Id”: 456,
“CustomerId”: 23,
“FirstName”: Max,
“LastName”: Black,
“EmailID”: Max.Black@123.com,
“MobNumber”: 12345789
},
{
“Id”: 234,
“CustomerId”: 233,
“FirstName”: Maxie,
“LastName”: McBlack,
“EmailID”: Max.Black22@123.com,
“MobNumber”: 1123457839
},
{
“Id”: 123,
“CustomerId”: 23,
“FirstName”: Maxxre,
“LastName”: Gold,
“EmailID”: Maximum.Black@123.com,
“MobNumber”: 1234500789
}
]

How I found the problem:

I’ve already tried:

Hi, if you want 3 random examples within your response, the easiest way would be to code the response to include 3 random examples :slightly_smiling_face: Like this:

Example Response
[{
    "Id": {{$randomInt}},
    "CustomerId": {{$randomInt}},
    "FirstName": "{{$randomFirstName}}",
    "LastName": "{{$randomLastName}}",
    "EmailID": "{{$randomEmail}}",
    "MobNumber": "{{$randomPhoneNumber}}"
 },{
    "Id": {{$randomInt}},
    "CustomerId": {{$randomInt}},
    "FirstName": "{{$randomFirstName}}",
    "LastName": "{{$randomLastName}}",
    "EmailID": "{{$randomEmail}}",
    "MobNumber": "{{$randomPhoneNumber}}"
 },{
    "Id": {{$randomInt}},
    "CustomerId": {{$randomInt}},
    "FirstName": "{{$randomFirstName}}",
    "LastName": "{{$randomLastName}}",
    "EmailID": "{{$randomEmail}}",
    "MobNumber": "{{$randomPhoneNumber}}"
}]

Which generates this output:

Generated Response
   [{
        "Id": 474,
        "CustomerId": 365,
        "FirstName": "Torrey",
        "LastName": "Marks",
        "EmailID": "Junius.Kulas@gmail.com",
        "MobNumber": "831-839-3312"
     },{
        "Id": 429,
        "CustomerId": 635,
        "FirstName": "Khalil",
        "LastName": "Bartoletti",
        "EmailID": "Eleonore.Ondricka@gmail.com",
        "MobNumber": "996-417-3307"
     },{
        "Id": 396,
        "CustomerId": 853,
        "FirstName": "Jerrold",
        "LastName": "Toy",
        "EmailID": "Keshawn.Funk@hotmail.com",
        "MobNumber": "796-698-1469"
    }]

If you want a way to programmatically generate x objects in your response, I’m not familiar of a way of doing this, hence I’m sharing this in case somebody comes along with a better solution for that!