Skip to content

Query parameters in collections #2428

Answered by CodeShakingSheep
absid89 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @absid89 ,
I just found a solution to your question. In a collection you can write a pre request script like this.

const queryParam = "page=3";
req.setUrl(req.getUrl().includes("?") ? req.getUrl() + "&" + queryParam : req.getUrl() + "?" + queryParam);

Collection pre request script:

Request timeline with appended query parameter:

You can see that the query parameter defined in pre request script is appended to the end of the URL.

Hope this helps. Cheers.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@absid89
Comment options

@CodeShakingSheep
Comment options

Answer selected by absid89
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants