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.