Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

358
Views
How do I automate saving a Postman response to a file using a test script

I am using Postman to access our LMS provider's site to retrieve datasets via API. There are 60+ datasets daily and manual download is tedious at best. Looking to be able to run the postman collect and save the response to a zip file on my computer's local drive. The response can be saved manually in Postman as a zip file. The response, according to LMS documentation is a zip file. However, using the script below with a local Python webserver running, the result is a file that cannot be opened.

API call: Get {{domain}}/api/lp/{{lpversion}}/dataExport/{{xxx}}/download/{{dataId}}

The response is binary data that when saved by Postman is a .zip file and is usable.

Here is my test script to attempt to save the response:

// The opts for the server, also includes the data to be written to file
let opts = {
    requestName: request.name || request.url,
    fileExtension: 'bin',
    mode: 'writeFile', // Change this to any function of the fs library of node to use it.
    uniqueIdentifier: false,
    responseData: pm.response.text()
};

pm.sendRequest({
    url: 'http://localhost:3000/write',
    method: 'POST',
    header: 'Content-Type:application/JSON',
    body: {
        mode: 'raw',
        raw: JSON.stringify(opts)
    }
}, function (err, res) {
    console.log(res);
}); 

Using this script while running a Python local webservice, I do get a file saved with a .bin extension. When I try to extract the data from the file, I receive an error.

I have tried changing the var fileExtension to 'zip', 'json' and 'txt. I receive the same error message with each.

Any help is greatly appreciated.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!