Hello! I am trying to automatically save a formatted response as an example on the request in my post-request script, but not seeing a way to accomplish it! I know I could click the “Save Response” button, but I would like it to update whenever the request is made so I would rather have it happen automatically.
Has anyone done this before or know of any ways to set that in my script? Thanks!
On the surface this doesn’t seem like a good idea. Is your API response schema changing often enough where it needs automatic updates? That makes me a little scared
That said, the only way I can think of doing something like that would be through the Postman API, but I can’t find an endpoint that adds an example to a request.
What’s your use case here? I’d love to learn more about what you’re doing!
Mostly as a way of collating the responses from a few different calls in a single area. There are two different third party services I am calling in a Postman folder and then I would manually put the data together to be consumed downstream either by someone reviewing manually or saving to a file to be consumed by a console app. I was hoping to do that data structure in the Post-request script and then save it as the example response as a way of saying “When I am done making these calls, this is what the data looks like” or to have it available in the same format consistently if someone else would need to run them. With the limitation on not being able to save or export to a text file on disk, I had hoped this would be a next best solution to have it visible and available!
You could save it as an environment variable. Those are accessible post run. It still feels like a two step process, but it works.
Or you could even create your own API endpoint that takes your consolidated object and does something with it. Then just call your endpoint at the end of the collection.
Both true! Was hoping to minimize overhead or additional knowledge someone might need to have in order to view or utilize the data, but those seem like the best solutions available to me with the current capabilities of Postman!