Currently while using Postman, I am facing an issue where I am not able to read content from local json file. The content from this json is stringified using bash commands.
Context:
I have yaml file and converted that to json using yq -o=json eval test-yaml.yml > testData.json
.
Next I stringified this JSON using jq -Rs '.' testData.json
.
Now I want to use this stringified JSON in an API's body. I tried assigning the output of above variable to env variable in bash, but somehow that doesn't work. I checked various posts on reading local file in Postman pre-request script, but I getting nowhere near useful data.
I tried using below method, but it ends up with Error: Cannot find module '~/workspace/source.json'
var fs = require('fs');
var data = fs.readFileSync("~/workspace/testData.json");