How to extract JSON data from external file as Datasource via Ready API?
- 7 years ago
Hi,
It's probably possible to grab .json from individual cells/rows in a spreadsheet but why would you want to?
I have lots of tests where I have individual test data saved in .json files (each file corresponds to a test/request) - I use the 'directory' datasource option.
This allows you to pass the whole file contents to a single property to then POST the filecontents via the property in a subsequent SOAP/REST request.
This option enables me to loop through multiple files (multiple files in a single directory) or just a single file in a single directory for a non-looped execution run.
So a simple test case hierarchy is as follows:
Datasource (directorytype) - fileContents property created (multiple .json files in directory) POST (${DataSource#fileContents}) <-- property specified in request body sources the fileContents property DatasourceLoop (loops back round to the next file in the directory - repeats until all files in directory have been processed
You can also paste the .json content into the body of your POST/PUT/PATCH requests - however this doesn't lend itself to looping test cases and also I find makes updating the testdata more difficult.
Sure the other users will have lots of other options for this - but this tends to be my goto approach.
Cheers,
richie