Automating Response Example Creation

Is there a way to automate the creation and saving of response examples by just running a test collection and saving the responses automatically as examples that can be referenced in documentation? Going through 100+ api requests to save examples is too tedious a job to justify imo. The documentation does not mention this feature, and would like to know if anyone else has gotten this to work before I create an issue on github.

Hi @fatima You should be able to do this using scripts inside Postman. So what you essentially need to do is

  1. In your test script Parse the response of the request.
  2. Using Postman APIs update your current collection. You can use pm.sendRequest to make an API call from your test script.
  3. And because you need to do this for all your requests inside a collection, I would recommend you add this script at the Collection level

For reference, you can also check out this blog post https://medium.com/postman-engineering/https-medium-com-postman-engineering-fake-it-till-you-make-it-mocks-for-agile-development-f4d050cad694

1 Like

Ah, I hadn’t even thought of that. That’s a great idea actually. Thank you so much!

1 Like