https://github.com/matt-ball/postman-read-file
Read a local data file on a per request level.
https://github.com/matt-ball/postman-read-file
Last synced: 3 months ago
JSON representation
Read a local data file on a per request level.
- Host: GitHub
- URL: https://github.com/matt-ball/postman-read-file
- Owner: matt-ball
- License: mit
- Created: 2019-08-07T22:18:45.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-11T01:20:31.000Z (over 2 years ago)
- Last Synced: 2025-01-12T18:14:39.274Z (5 months ago)
- Language: JavaScript
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Postman Read File
Read a local data file on a per request/folder level.
## Setup
Clone this repo. `npm i` then `node index.js`.
Add this snippet to the `Pre-Request Script` of your request or folder.
```
pm.sendRequest({
url: `localhost:3000?path=/Users/matt/data.csv`,
method: 'GET'
}, (err, res) => {
res = res.json();
pm.globals.set('file', JSON.stringify(res));
});
```## Usage
Change the `path` parameter in the above snippet to point at the local file you'd like to read. If the file is a `.csv` extension, it'll automatically be converted to JSON. If it's already JSON, it'll come through exactly as authored.
The above snippet will set the entire file into a global Postman variable called `file`, but you can customize this to your hearts content.