Write to FIle/Save to File

Is there a simple solution for saving a file to a file location without having to click the Send & Download button. I am working on a few calls that pull data from a web application. I successfully can pull the data but need to include the writing/saving of the file to a specific file location. In this case I can pull out the code in Python script and automate it.

I was able to find some docs in various forums for a template called Write to File but it requires to save / download files to my machine, and unfortunately my company has a restriction on this.

Is there a way I can take the response and create some type of script in the β€œTest” handling section to accommodate this?

Hi @slavsnitkovskiy,

Welcome to the community! :clap:

So upon reviewing the documentation here:
https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/

It doesnt look like the β€˜fs’ module is available in postman, which limits writing to file or saving with the request.

However, you should be able to save the response using Collection Runner. You can create a datafile or put the data in your environment, run the collection and set the response to save, and it should work automatically. Refer here for more information on how to set it up.

https://learning.postman.com/docs/running-collections/intro-to-collection-runs/

Hope this helps!