Is postman just for testing or can I use it to script a production routine?

The Postman website uses the term ‘testing’ to describe it’s purpose. I can test the API I need to pull data from using Postman, which is already useful. I am wondering if I can also use Postman to script the connect and download the json data as part of a set of routines that can be automated via powershell and task manager (or whatever) to make the requests?

2 Likes

Why not?

If you are able to do exactly what you need to do through the execution of APIs, then go for it. Postman has a number of triggers that can kick off workflows, so you’re set.

1 Like

Sounds good I’m checking it out. Thank you!

I have a GET request in a collection called openweathermap. When I run the request in postman, I get the json payload. That collection is also listed in Collection runner, but when I select it and click “Run openweathermap”, it fails 0 Passed 0 Failed. The specific error is
GET
Error: runtime:extenstions~request: request url is empty
In postman, all I’ve done is fill out the testing url…do I need to save it or something of that order, so that Runner knows the url? Otherwise how do I inform Runner of the url?

yes you have to click save .

image

Make sure the orange dot is removed , the dot indicates there are unsaved changes

Hi @salmon. just to add on to the above points, if you have defined the URL as an variable of your scope, by hovering over that you can check if the value is present for it not

If this variable looks red, its unresolved !

Thanks both of those are useful. The url issue is resolved - it turns out there was no url in postman, I was looking at the wrong request. Now it says “This request does not have any tests”. Hints appreciated but I just need to read a bit about this I’m sure.

tests are those defined inside pm.test() function in the test script section .

There are snipet already available for most of the tests :slight_smile:

just click test tab , in the right side scroll to status is 200 and it creates the code for asserting that status code is 200

OK thanks, the status code 200 test is created and allows the collection to run.
I would like to save the results of the api call (not the test outcome) to a file after each run. How can that be done?

Hi! If you want to save a response body to a file, you can do so by clicking on “Send and download” when you send a request.
Screen Shot 2021-01-07 at 4.40.53 pm

Alternatively, if you want to save response of whole collection run, you can use newman as suggested here:

Thanks taehoshino, useful. Is there a way to get runner to save the response body to a distinct file when it runs every hour? Or otherwise record the payload in a storage format, such as a database?

Hey, @salmon!

If you use newman to run a collection (instead of runner in the native app), you can certainly save the output to a different file, however, I don’t think you can do so from the runner.

Alternatively, you can probably set a environment/collection variable and store the response, similar to the one suggested here.