How to change key part of query string dynamically in karate

Viewed 26

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.

  • string reqBody = version == 'v2' ? 'ABC' : 'DEF'
  • string paramName = version == 'v2' ? 'json_body' : 'proto_body'
  • param paramName = reqBody

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

1 Answers
Related