How to call many requests at once using CSV, with single iteration

Hello all, as an addition to my previous topic that I couldn’t find an answer: How to combine several json bodies with same structure but different values in 1 request I’d like to ask my question in other words.
I have a collection of requests:

  • Create account
  • Login
  • Start - (showing what the first question will be)
  • Next question - I can call every single question with this request and depending on the response I can call the next one with the same request.
    I’m using this approach at the moment, but with many “Next question” POST requests.

My task is to call them with a single request.
How to do that using CSV file? The main thing is to check if every next question is the one that is expected.

Best regards,

I assume you mean a single request that you iterate over a bunch of times?

So you’re sending a request and it comes back with a “next question” value. You want to do an assertion on that value then start the loop again?

That’s correct, I’m sending a request and it comes back with a ‘next question ID’.
Here you can see my body every time:
{
“answerBody”: {“value”: “{{answerBody}}”}, - different every time
“answerType”: {{answerType}}, - can be the same or different
“answerGroupId”: {{answerGroupId}}, - can be the same or different
“id”: {{id}} - next question’s ID (different every time)
}

So I need to repeat this until the last question. I also need to do it with a single request and using CSV file.
I hope it’s clear.

Best regards,

Why do you need to do it with a CSV and have it be dynamic? Those things don’t seem to go together.

What data is coming out of the csv?

If I understood correctly, you need to take the id from response of your previous request and take other values from .csv file.

To do so you can update the environment or collection variable and set the questionId from there using test script. That value set can be used in next iteration. Rest values could be taken sequentially.

Hope this helps

1 Like

@pranavdavar, You understand it correct! I like the suggestion, but may I see how the test script should look like?

Thanks in advance!
Best regards

@allenheltondev, This is my task, that’s why. CSV will contain variables, so I can take everything from there.

Best regards.

I am assuming, the response from the previous request looks as below.
{
“questionId”: “1234567890”
}
Test Script will look like:
pm.environment.set(pm.response.json().questionId,'id');
In the above example, I have used environment variables, you may use global or collection based on the requirement.

This variable value will be accessible in the next run as now I have set to the environment. Once the run is completed it will update the value, that could be fetched from response of the request.