How to store json value in external data for postman test

Hi guys,

for example I have an external json file like:
[{
“category”: “1”,
“example”: [
{
“Something”: {
“SomethingA”: “1086716”,
“SomethingB”: “300079”
}
}
]
}

how can I check in the test-script my request response, which is a json with the:
“example” value, which provides a json?

Thanks

Hi @Anton39,

We cannot access an external JSON file for a request but we can access a single external JSON file for a collection run.The external JSON file has to be imported as shown in the image before you run the collection.

If you would need to access the data within an imported JSON file and set it as an environment variable, you would have to execute the following command in your test script to get the example array:

var data = pm.iterationData.get(JSON.stringify(data[0].example[0]));
pm.environment.set(“example”, data);

Here is a link to an article describing collection runs:
https://learning.getpostman.com/docs/postman/collection_runs/intro_to_collection_runs/

1 Like