You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank for your reply. But I know that. I mean I want to read file (excel, text and so on) in tests during writing my code in java script in postman. Do you know how?
Any progress on this? Would really like the ability to load some complex data from files during Pre/Test Script. For example, I would like to load a JSON file which contains the expected response JSON schema. This would allow me to externalize the schema from the script and re-use it across multiple collections while only maintaining a single copy.
Currently I am stuck duplicating these schema definitions across many collections (or I need to set a global variable before running which is not desired). If the schema changes I will have to update dozens of collections that use it.
leonelgalan, npenteado, amwebexpert, selfboot, prashant7090 and 15 more
Would be very interested in using that in our postman-sheme, too.
Our API calls are expensive, and we would have several dozen tests per call, which we now have to fill in per hand. One Test per call would take hours in our system.
Using a csv for that would be so much more effective.
Would be cool to have somthing like this! We're doing JSON validation via tv4 in Jenkins/newman. The json-schema gets generated dynamically by a pre-executed server script. Loading this file would be much easier than deploying it somewhere and calling it via HTTP.
I'm interested in this feature too. I want to reuse JSON schema files I have, in both, RSpec and Postman/newman, the current solution is to write the schema into every Postman test.
A workaround for now is to start a local server (https://www.npmjs.com/package/simplehttpserver), and use a Postman request and test script to load the response into an environment variable.
Since we need to support collections in the cloud as well, this isn't on the immediate roadmap.
One solution might be to have your developers load the data to the application under test from csv, then expose that data via an end point. You can then load that as Global Variables using an initialisation script. Not pretty of course but it works.
Instead of copy and paste the JSON in body of the request, I would like to read it from JSON file (external source) and then replace all dynamic variables from JSON file.
e.g. Below is my JSON file which I want to read it from my hard disk and replace all variables with valid values before sending it.
{
"firstName": "{{firstName}}",
"lastName": "{{lastName}}",
"age": {{age}},
"correlationIds": [
{
"id": "{{id}}",
"source": "{{source}}"
},
{
"id": "{{id2}}",
"source": "{{source2}}"
}
]
}
i need postman read my large of test cases from csv, the csv filles contains URL, header, body and expeccted responses to assertion. i hope pm can make it.
I want to read a local file and parse it in tests in postman and I can't able to do this
check this out
The pre-request and test script sections of the Postman app rely on JavaScript (not text). Therefore, you can use Postman’s pm.* API, like the pm.iterationData.get(“variable-name”) method, to access the values loaded from the data file.
I'm unable to read the values in pre-requisite scripts when I read the data file from server in the pre-requisite script. Is this feature not available in Postman?
Activity
abhijitkane commentedon Nov 11, 2014
You can use the collection runner to load data files into Postman.
Check https://www.getpostman.com/docs/jetpacks_examples for examples. JSON and CSV are supported.
hanyghazal commentedon Nov 11, 2014
Thank for your reply. But I know that. I mean I want to read file (excel, text and so on) in tests during writing my code in java script in postman. Do you know how?
abhijitkane commentedon Nov 11, 2014
That's currently not supported - we're working on a way to include custom files in the Pre-request scripting / testing sandbox.
xiaobeiying commentedon Nov 28, 2016
@abhijitkane Looking forward to the NEW version.
garunski commentedon Jan 10, 2017
+1
bennetone commentedon Feb 22, 2017
+1
barnesm999 commentedon Apr 12, 2017
Any progress on this? Would really like the ability to load some complex data from files during Pre/Test Script. For example, I would like to load a JSON file which contains the expected response JSON schema. This would allow me to externalize the schema from the script and re-use it across multiple collections while only maintaining a single copy.
Currently I am stuck duplicating these schema definitions across many collections (or I need to set a global variable before running which is not desired). If the schema changes I will have to update dozens of collections that use it.
ji50180 commentedon May 10, 2017
Would be very interested in using that in our postman-sheme, too.
Our API calls are expensive, and we would have several dozen tests per call, which we now have to fill in per hand. One Test per call would take hours in our system.
Using a csv for that would be so much more effective.
saschawiener commentedon Jun 14, 2017
Would be cool to have somthing like this! We're doing JSON validation via tv4 in Jenkins/newman. The json-schema gets generated dynamically by a pre-executed server script. Loading this file would be much easier than deploying it somewhere and calling it via HTTP.
leonelgalan commentedon Jul 7, 2017
I'm interested in this feature too. I want to reuse JSON schema files I have, in both, RSpec and Postman/newman, the current solution is to write the schema into every Postman test.
Rachit1980 commentedon Aug 14, 2017
Need a way to read a txt/CSV file in tests and compare values to JSON element values
abhijitkane commentedon Sep 11, 2017
A workaround for now is to start a local server (https://www.npmjs.com/package/simplehttpserver), and use a Postman request and test script to load the response into an environment variable.
Since we need to support collections in the cloud as well, this isn't on the immediate roadmap.
prashant7090 commentedon Nov 30, 2017
@barnesm999 Hey did you get any solution to externalize the JSON response schema files?
Kal6 commentedon May 2, 2018
Is there any new developments on this feature? It would be nice if we have it to handle the data from outside of the scripts.
Thank you!
christianbaumann commentedon May 28, 2018
+1
RickHough commentedon Jun 28, 2018
One solution might be to have your developers load the data to the application under test from csv, then expose that data via an end point. You can then load that as Global Variables using an initialisation script. Not pretty of course but it works.
nileshy112 commentedon Jul 16, 2018
Instead of copy and paste the JSON in body of the request, I would like to read it from JSON file (external source) and then replace all dynamic variables from JSON file.
e.g. Below is my JSON file which I want to read it from my hard disk and replace all variables with valid values before sending it.
{
"firstName": "{{firstName}}",
"lastName": "{{lastName}}",
"age": {{age}},
"correlationIds": [
{
"id": "{{id}}",
"source": "{{source}}"
},
{
"id": "{{id2}}",
"source": "{{source2}}"
}
]
}
trastle commentedon Oct 11, 2018
This is sorely needed for short lived tokens etc.
Manually copy pasting a token into postman every time my tokens expire is nuts.
Even something simple like use a JSON file for the environment of a folder would be a huge improvement.
ADaniel-dev commentedon Oct 25, 2018
i need postman read my large of test cases from csv, the csv filles contains URL, header, body and expeccted responses to assertion. i hope pm can make it.
junaidq57 commentedon Jan 30, 2019
check this out
The pre-request and test script sections of the Postman app rely on JavaScript (not text). Therefore, you can use Postman’s pm.* API, like the pm.iterationData.get(“variable-name”) method, to access the values loaded from the data file.
https://blog.getpostman.com/2018/04/11/looping-through-a-data-file-in-the-postman-collection-runner/
AshirwadVyawahare commentedon Feb 16, 2019
I'm unable to read the values in pre-requisite scripts when I read the data file from server in the pre-requisite script. Is this feature not available in Postman?
SHI-ZP commentedon Feb 18, 2020
Well, I suppose RickHough's solution would be the only approach.
rcmonitor commentedon May 24, 2020
Still looking for ability to load local file into string variable in pre-request script
VigneshOK10 commentedon Jun 29, 2020
any updates on provision for getting local files in tests?
arlemi commentedon Jun 30, 2020
This is not something we're working on at the moment, for any updates regarding this please follow #7210.
(closing to avoid more unwanted notifications from participants in this thread. 🙂)