Open bkcummins opened 3 years ago
Maybe this would work like saved examples. In this case, we could create multiple examples and use them in the body request. I work with an API with a lot of conditional fields and it is very annoying to create multiple requests for the same endpoint.
Super basic screenshot, but here's a rough idea.
At first i thought adding example will solve the problem, but examples can't be run as normal request, for now i need to copy paste from example to request and run it. Multiple requests for same url would be very usefull.
Any news on when this may be implemented? :)
This would be extremely helpfull.
I am waiting for this feature.. any update on this:-)?
At first i thought adding example will solve the problem, but examples can't be run as normal request, for now i need to copy paste from example to request and run it. Multiple requests for same url would be very usefull.
Maybe examples could be made "sendable" and possibly "request-only". That would solve it.
Indeed this would be a very useful addition. We are looking at automatically generating monitors from an OpenAPI spec that has multiple example bodies per request. Being able to natively support this instead of creating multiple requests using the Collection SDK would be an incredible time saver.
I haven't actually implemented this myself, but as a work-around, I could see using Collection variables for this. In one variable, you store an index. In another variable you can store a JSON string that has an array of your test cases - called testCases
- like so:
{
"testCases": [
"{\"name\": \"Bob\"}",
"{\"name\": \"Alice\"}"
]
}
Then in a pre-request script for the Request, you can do something like this, maybe? Changing the index variable when you want to switch to a different body.
const testCases = JSON.parse(pm.collectionVariables.get("testCases")).testCases;
pm.request.body.raw = testCases[pm.collectionVariables.get("index")];
Edit: added .testCases
to the end of the first JS line
This feature would be awsome as state above to run automated testing with different bodies.
This is a must have feature. It should permit store not only the Body section but also Headers and Params, included Query Params and Path Variables.
@ewilliams-zoot this work around is hard to maintain in practice. Each API request json string is not going to be nicely display in 1 line and editing something in it is error prone.
@yatw Yes, I agree 100%, but it's a work around that seems to have worked for me. I have since tried it on a project, and it is cumbersome to be sure.
Please bring this functionality to Postman, it really would make our lives a lot easier. Thanks. Onur
This feature would really help.
I would like this feature a lot. Any update?
@tylerthecoder They introduced a CLI with their latest updates; I haven't looked into it yet, but that may have the capability people in this thread are wanting. You can at least integrate whatever functionality they have in the CLI with a scripting language of your choice. I'm not sure that is better than my other suggestion above, to be honest.
I specially googled for this feature that led me to this thread... Would be an amazingly helpful feature
this would be a great feature :D
It will be super helpful, sometimes we need to leave different scenarios with different JSON Objects
Still looking forward for this feature
You can save these payloads as Examples
to document these different bodies and you can consume these trying the examples out. Attaching a short video on how i'd approach this. Let us know if this makes sense.
https://user-images.githubusercontent.com/1040583/221112612-ab608460-0896-47ae-8c0c-f2f62c62bcfe.mov
You can save these payloads as
Examples
to document these different bodies and you can consume these trying the examples out. Attaching a short video on how i'd approach this. Let us know if this makes sense.
This is somewhat convoluted way of achieving the requested functionality but it works. Thanks for sharing. Though I'd prefer directly saving and using multiple request bodies. Until it is implemented properly, this is the way to go.
Examples serve as scenarios and documenting what the API is capable of, and thus seems like the perfect place to store multiple json objects for a given request. This way its also easier for your collaborators to understand. Also looking from the previous comments, it seems like one of the blockers all these days was the inability to send examples - this was addressed recently in a release. Would love to know your use cases in depth to see if this needs a different solution.
Linking this issue (sendable examples): https://github.com/postmanlabs/postman-app-support/issues/3694#issuecomment-1433299057
We use examples for this and works perfectly for showcasing different payloads an endpoint can accept
It would be very helpful to be able to store multiple request body (json) objects for a saved endpoint so that you could toggle between them for test data.
There is a similar option in AWS Lambda to store incoming test events. Thx in advance! https://aws.amazon.com/blogs/compute/improved-testing-on-the-aws-lambda-console/
I accomplish this now by saving the same endpoint configuration multiple times with different request bodies, but a drop down interface would be ideal.
Thx in advance for consideration!
Shared originally on the community forum. https://community.postman.com/t/store-multiple-request-body-json-objects/20315