1

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 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.