Generate Runner data file from API results

Hello Postman Community,

I’m developing with my team a lot of APIs (through an API Manager) that I would like to test with Postman. All of these APIs must meet common requirements and must therefore be subject to the same tests (verification of responses in case of incorrect completion of mandatory headers, etc.). For this, I use the Postman runner, in which I enter a data file containing the names of the routes to be tested.

The number of APIs to test changes every day and keeping the data file up to date takes time. For this reason, I would like to generate this data file on the fly through a query on the OpenAPI specifications of our APIs.

Here is my target scenario:

  • a developer of my team launches the runner;
  • a first request retrieves OpenAPI specifications of all our APIs;
  • the list of API routes to be tested is generated based on the response with js;
  • the runner iterates several times over all the tests.

How could I implement this use case?

Are there any Postman features that would meet this need?

Thank you very much for your answer,

Best regards,

Grégoire Thibaud

Hi @Gregoire_Thibaud,

Welcome to the community!

This should be doable. I’d create two requests in your Collection:

1st request: pull the list of endpoints, use JS in a test script to structure the response data and store it as a local variable using pm.variables.set('key','value');

2nd request: grab and parse the response data you previously stored (JSON.parse(pm.variables.get('key'))), run your tests, and loop the request the using Postman.setNextRequest('request_name') in the test script.

Depending on how you structure your response data, you could store and increment a counter in a local variable (pm.variables.set('counter',value)) to keep track of which endpoint to hit next in the loop, and determine when to stop by setting the next request to null (postman.setNextRequest('null')).

Hope that helps! Let me know if you have any questions. :slight_smile:

1 Like

Hello John-Paul,

Thank you very much for your clear response. This is exactly what we need :grinning:

We hope Postman will offer an advanced graphical workflow tool for the Runner in future updates… :blush:

Thank you for your time!

Have a great day,

Grégoire Thibaud