Closed dremekie closed 1 year ago
@dremekie The easiest way would be to import the file directly as a body. In this case the file is only read in as a buffer and not modified (config property should be added to json file)
POST {{gatewayUrl}}/saveConfig
Content-Type: application/json
< ./myJsonFile.json
Another solution would be to use the escaped variant \{\{...\}\}
instead of {...}}
in the template string. This will then be automatically replaced correctly (see example)
Another possibility would be to set the body directly as a buffer. The body would no longer be adjusted and sent.
{{
const fs = require('fs');
request.body = Buffer.from(`{ "config": ${fs.readFileSync('myJsonFile.json', 'utf8')}`);
}}
POST {{gatewayUrl}}/saveConfig
Content-Type: application/json
Thanks
Any of the above POSTs result in
ERROR: ReferenceError - title is not defined
.myJsonFile.json
is a JSON document that contains strings with {{title}} in it as well as many other strings with {{xxx}} that should be POSTed to the endpoing as-is. I cannot escape them with\{\{
because they are needed as-is by other processes.Is there a way to NOT perform variable substitution within the actual variable data (i.e.myJsonFile) ?