How to use dynamic variable in request URL

Hello everybody,
I have specefic case and need some help.

Request URL:
KEY:                                  VALUE:
query_xml                          <ROWDATA type="Bank_LogIn">

Pre-request Script:
const query = pm.request.url.query.all();
let bank = "";
query.forEach((p) => { if (p.key == "BANK") bank = p.value });
pm.environment.set("BANK", bank);

// default Values. Could be overWritten in switch case.
pm.variables.set("BANK_REQID", "test");
pm.variables.set("BANK_PASSWORD", "password");

switch (bank) {
    case "ACRA":
        pm.variables.set("BANK_USER", "login");
        pm.variables.set("BANK_PASSWORD", "password");
    case "ABB":
        pm.variables.set("BANK_USER", "login");
        pm.variables.set("BANK_PASSWORD", "password");
    case "ACBA":
        pm.variables.set("BANK_USER", "login");
        pm.variables.set("BANK_PASSWORD", "password");
        pm.variables.set("BANK_REQID", "");
        pm.variables.set("BANK_USER", "");
        pm.variables.set("BANK_PASSWORD", "");

This is my structure where I can send request and log in. When I want to log in to ACBA(for example) I have to change into request URL and write ACBA manually.
Is it possible to log in dynamically to banks for each successive request?

Could anyone help me, please?

@vdespa could you help me, please?

I would recommend simplifying the problem, breaking it down into smaller steps.

The script that you have, the part with forEach does not make much sense to me.

If you want to reuse the same request, you may want to get familiar with data-sets which you can provide with a CSV or JSON file or use postman.setNextRequest.

Thanks for your reply @vdespa .
I don’t want to reuse the same request as it is. As you can see above bank value is ABB, I want to set dynamic variable instead of fix value. I want to avoid from manual input. Is there any way to do that?

Sure, use


Ok, then use CSV or JSON file?
Isn’t there any way to build structure without selecting file(JSON or CSV), because I want to login to the first bank(ACRA), then request another endpoint, then again login to the second bank(ABB) … and so more than 20 times.
I have two endpoints-one is mentioned above.

Let me show screenshots. This is login request.

This is second endpoint.

Which steps have you taken to simplify your problem or to break it down into smaller pieces?

Sorry for late reply, I was really busy.
I have tried data-sets, but that doesn’t solve my problem, that is why I wrote the previous reply.
I have no idea if there is any solution or not.