Create a JSON Data File - Example 1
GET https://randomuser.me/api?results=5
Basic Default Usage
The default URL https://randomuser.me/api?results=5
is going to make a request to the randomuser API and return 5 individual users with a different data set.
This script in the Tests
tab is mapping certain parts of this response body and creating a new data set in the format that the Collection Runner accepts.
If you're happy with the data in the Data File Preview
panel, press the Create Data File
button.

Pressing the Download Data File
button will open your local file explorer, from here you can save the data.json
file in a local directory.

The saved file can then be used in your Collections, the object keys fullName
, email
and gender
would be the variable names that you would use in your requests.
[
{
"fullName": "Ms Sheryl Neal",
"email": "sheryl.neal@example.com",
"gender": "female"
}
]
A basic example of a POST body:
json
{
"fullName": "{{fullName}}",
"email": "{{email}}",
"gender": "{{gender}}"
}
Changing the script to create your own data files
A basic JSON Response Body:
{
"results": [
{
"gender": "male",
"name": {
"title": "Mr",
"first": "Flynn",
"last": "Thomas"
},
"location": {
"street": {
"number": 4474,
"name": "Taharoto Road"
},
"city": "Taupo",
"state": "Bay of Plenty",
"country": "New Zealand",
"postcode": 17489,
"coordinates": {
"latitude": "60.2359",
"longitude": "-175.9986"
},
"timezone": {
"offset": "-6:00",
"description": "Central Time (US & Canada), Mexico City"
}
},
"email": "flynn.thomas@example.com",
"login": {
"uuid": "6b37db11-6302-461e-a569-4c58a7558a0a",
"username": "greenmeercat326",
"password": "elcamino",
"salt": "zocjzh45",
"md5": "69c79a8d481718c0046d5ef8d25e6375",
"sha1": "a0b93772355e80ad07b3c7ac8e846dfaa83cba63",
"sha256": "a0329b516d4504a33ec296d98e87b3ff57e4aea05bd213470b4e5a4c7b35fbe7"
},
"dob": {
"date": "1986-06-26T13:02:49.307Z",
"age": 34
},
"registered": {
"date": "2007-12-17T18:55:08.494Z",
"age": 13
},
"phone": "(643)-356-0648",
"cell": "(265)-043-3830",
"id": {
"name": "",
"value": null
},
"picture": {
"large": "https://randomuser.me/api/portraits/men/52.jpg",
"medium": "https://randomuser.me/api/portraits/med/men/52.jpg",
"thumbnail": "https://randomuser.me/api/portraits/thumb/men/52.jpg"
},
"nat": "NZ"
}
]
}
The script in the Tests
tab can be modified to capture data from any Response Body.
For the example response above, all the data is inside the results
array []
so to reference this in the script you would use pm.response.json().results
, if the data was in a different array, you would just need to change results
to the value in your response.
The .map()
function will loop through the array and store different parts of the data in the container
object.
The email
part of container.email
would be the property name that the value from the response would map too.
The email
part of item.email
would be the key
to the value
you would like to capture. The example body should hopefully help you understand how this all ties together and serve as a reference guide when changing the script to suit your own context.
let myfileData = pm.response.json().results.map(item => {
const container = {};
// Specify the values from the response body that you require in the Data file.
container.fullName = `${item.name.title} ${item.name.first} ${item.name.last}`;
container.email = item.email;
container.gender = item.gender;
return container;
});
Once you have a data file created, you will be able to start using this in the Collection Runner.
More information about how to use these can be found [here]
Request Params
Key | Datatype | Required | Description |
---|---|---|---|
results | number |
RESPONSES
status: OK
{"results":[{"gender":"female","name":{"title":"Mrs","first":"Andrea","last":"Larsen"},"location":{"street":{"number":7250,"name":"Havnegade"},"city":"Sørvad","state":"Midtjylland","country":"Denmark","postcode":96458,"coordinates":{"latitude":"-36.6934","longitude":"63.1713"},"timezone":{"offset":"+9:00","description":"Tokyo, Seoul, Osaka, Sapporo, Yakutsk"}},"email":"andrea.larsen@example.com","login":{"uuid":"168eb4e5-f3bd-4658-8c9b-8b65d86ddc76","username":"sadleopard752","password":"miguel","salt":"lS2zwIaW","md5":"4c387f11a008bef881304679115f33e8","sha1":"245443050fd361c58bf906928c5e63562a00616e","sha256":"d54c72c619f0fb69203bc5da4594f621dcf6e95f135f03b458e0ea7a7a4bb092"},"dob":{"date":"1966-08-01T19:16:49.991Z","age":54},"registered":{"date":"2008-04-22T06:12:06.269Z","age":12},"phone":"54887431","cell":"45456332","id":{"name":"CPR","value":"010866-1094"},"picture":{"large":"https://randomuser.me/api/portraits/women/80.jpg","medium":"https://randomuser.me/api/portraits/med/women/80.jpg","thumbnail":"https://randomuser.me/api/portraits/thumb/women/80.jpg"},"nat":"DK"},{"gender":"male","name":{"title":"Mr","first":"Jeff","last":"Brewer"},"location":{"street":{"number":2967,"name":"Springfield Road"},"city":"Cardiff","state":"County Antrim","country":"United Kingdom","postcode":"V0C 8EF","coordinates":{"latitude":"-66.3687","longitude":"-9.0829"},"timezone":{"offset":"-6:00","description":"Central Time (US \u0026 Canada), Mexico City"}},"email":"jeff.brewer@example.com","login":{"uuid":"868a5532-0f68-4171-b4c2-21a133523e1c","username":"silverkoala775","password":"airwolf","salt":"Nfmpukp6","md5":"3df6efd2e7a927c4fe2121319a938934","sha1":"6e3832ec3ba9b372e58716ac2147b8773733e3ec","sha256":"a4e088edf799a1254ed29ba4848192321840308905917f9b593b72b77149d886"},"dob":{"date":"1953-08-19T17:52:06.090Z","age":67},"registered":{"date":"2010-03-22T19:43:36.251Z","age":10},"phone":"016977 47269","cell":"0762-617-955","id":{"name":"NINO","value":"BJ 27 99 94 H"},"picture":{"large":"https://randomuser.me/api/portraits/men/73.jpg","medium":"https://randomuser.me/api/portraits/med/men/73.jpg","thumbnail":"https://randomuser.me/api/portraits/thumb/men/73.jpg"},"nat":"GB"},{"gender":"male","name":{"title":"Mr","first":"Loris","last":"Brun"},"location":{"street":{"number":2278,"name":"Rue D'Abbeville"},"city":"Lille","state":"Landes","country":"France","postcode":24086,"coordinates":{"latitude":"-12.2606","longitude":"90.3826"},"timezone":{"offset":"+3:00","description":"Baghdad, Riyadh, Moscow, St. Petersburg"}},"email":"loris.brun@example.com","login":{"uuid":"27bf3009-37f6-47d5-a21f-8bcec8eace08","username":"silverbird589","password":"bigpoppa","salt":"eYzfbvvR","md5":"38da1751210af806583c6f894f5c9da0","sha1":"110407d1ef72be870367abc22bb7cfbc0849a645","sha256":"1806efeb73b3acf783fdce0f3e8f21b8d7c4b677bf77d5965f6130250abdef65"},"dob":{"date":"1986-05-28T11:59:19.863Z","age":34},"registered":{"date":"2010-11-25T16:30:45.036Z","age":10},"phone":"02-20-85-13-51","cell":"06-29-31-77-92","id":{"name":"INSEE","value":"1NNaN70189505 96"},"picture":{"large":"https://randomuser.me/api/portraits/men/1.jpg","medium":"https://randomuser.me/api/portraits/med/men/1.jpg","thumbnail":"https://randomuser.me/api/portraits/thumb/men/1.jpg"},"nat":"FR"},{"gender":"male","name":{"title":"Mr","first":"Pedro","last":"Meyer"},"location":{"street":{"number":7342,"name":"Ringstraße"},"city":"Solingen","state":"Sachsen","country":"Germany","postcode":62216,"coordinates":{"latitude":"-85.1557","longitude":"143.8347"},"timezone":{"offset":"+4:30","description":"Kabul"}},"email":"pedro.meyer@example.com","login":{"uuid":"27955d19-7a8a-46aa-a652-47dacf16a412","username":"whiteduck711","password":"babybaby","salt":"EZv8VO42","md5":"81847c054b35bf99df56af1ee5c1c038","sha1":"6d196981ce8a1e873c0219f71a00f741c3762209","sha256":"311595f0894e9ff1f2248baab1b3497fd360462a6a589ee425a4bf45daf64d02"},"dob":{"date":"1945-01-08T10:16:44.575Z","age":75},"registered":{"date":"2006-03-22T06:29:49.777Z","age":14},"phone":"0128-5716497","cell":"0176-9205774","id":{"name":"","value":null},"picture":{"large":"https://randomuser.me/api/portraits/men/11.jpg","medium":"https://randomuser.me/api/portraits/med/men/11.jpg","thumbnail":"https://randomuser.me/api/portraits/thumb/men/11.jpg"},"nat":"DE"},{"gender":"male","name":{"title":"Mr","first":"Onur","last":"Solmaz"},"location":{"street":{"number":3326,"name":"Mevlana Cd"},"city":"Burdur","state":"Kahramanmaraş","country":"Turkey","postcode":61622,"coordinates":{"latitude":"61.5211","longitude":"-119.5220"},"timezone":{"offset":"-2:00","description":"Mid-Atlantic"}},"email":"onur.solmaz@example.com","login":{"uuid":"7f8fa1fc-eb4a-47c3-9eb9-3f23a67c37c6","username":"angrypanda947","password":"dododo","salt":"JVRrYjP5","md5":"ac94ac51263d6fa2903bb411e2c07dee","sha1":"46007a490d3c72abf64a381b4d4ff3484a66ea31","sha256":"96d4270225673e4686052e119f46c7fdd3e7ec237e9a9f38c86dc21951c4fe1c"},"dob":{"date":"1998-07-08T22:48:04.534Z","age":22},"registered":{"date":"2005-01-17T06:49:12.240Z","age":15},"phone":"(953)-867-9924","cell":"(308)-904-1673","id":{"name":"","value":null},"picture":{"large":"https://randomuser.me/api/portraits/men/75.jpg","medium":"https://randomuser.me/api/portraits/med/men/75.jpg","thumbnail":"https://randomuser.me/api/portraits/thumb/men/75.jpg"},"nat":"TR"}],"info":{"seed":"7f650a8009c2b4aa","results":5,"page":1,"version":"1.3"}}