Deepak Rai
Deepak Rai

Reputation: 212

How to change key part of query string dynamically in karate

I have the below requirement where I need to dynamically change the key-value pair of the query string, but I am able to dynamically change the value of the query parameter but not the key part. It is taking the text value like 'paramName' in the request.

GET https://test.apis.com/sample?paramName=ABC or GET https://test.apis.com/sample?paramName=DEF

Upvotes: 1

Views: 355

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58058

If you need dynamic param names, use params: https://github.com/karatelabs/karate#params

* def temp = version == 'v2' ? { json_body: 'ABC' } : { proto_body: 'DEF' }
* params temp 

If you still have questions, read this: https://stackoverflow.com/a/50350442/143475

Upvotes: 2

Related Questions