How to manage dynamic request body & dynamic tests in case when there is different response codes for the each request?

Your question may already have an answer on the community forum. Please search for related topics, and then read through the guidelines before creating a new topic.

Here’s an outline with best practices for making your inquiry.

My question:
I’m having a login API where I need to send an E-mail and Password in the request body. Now I need to test negative scenarios in the same single request. Generally, for the valid login, I’m getting 200 and for the invalid, I’m getting 400. I need to send an invalid email and password in the request body for this and need to capture the result and accordingly tests as well. How this can be achieved in a single request?

Details (like screenshots):
Request Body
“email”: “”,
“password”: “”

How I found the problem:

I’ve already tried:
Tried with Data-driven at the time postman runner but then how to manage tests accordingly? I mean Iteration-wise tests and I can upload a single file for each API how to handle this situation when we will plan to run all APIs as a whole where we may require to send different request bodies every time for each API? We might need those numbers of csvs and separate collections.

Don’t do it in the same request.

Have a separate request to the same end point for invalid emails.

You need to be in control of your test data. It needs to return the same result each and every time and you base your tests on those results.

If you want to test difference response codes, then you ensure that you have test data that will illicit that response. (Which means you might have more than one request to the same end point to test out all of these scenarios).

1 Like