Make request to API and safe the response in file

Hi guys,

I want to write a script, which makes an API call via Postman, and safes its response.
I want to ask you, if you have any hints about it, how to do it?

Thanks a lot

Hi @Anton39,

The following link which should answer your question:

The pm.sendRequest:Function allows sending HTTP/HTTPS requests asynchronously through the test script after which you can go ahead and save the response in a global variable or an environment variable based on your preference.

1 Like

I can include this API in javascript, and call the URL?

Yes, you can include this in the pre-request script or test scripts in Postman based on your preference.

1 Like


but I mean, I want to use a seperate javascript and include this API and then make the call and fetch the data.
By only using this API

I am not sure what you mean by using a separate JavaScript, my answer is relevant to scripting on Postman using the pm library.
If you are referring to triggering an API request on Postman using external JavaScript, that is not possible.

1 Like

@aamir.ahmed thanks,

I see, because my goal was to write a script, which can use the API of postman and do the calls and safe it as output for example in a file.
Means, I would like to run it in a console, modify some parameters in script and get the response in a data.