How to pass parameter in a JSON file in karate

Viewed 1029

I have my request body in a *.json file and same *.json request body with different parameters is used in multiple test scenarios. How to pass variables in this scenarios.

I tried below

* def requestBody = call read ('successScenario.json') { id: 'U123', age: 23, date: currentDate }
And request requestBody

Please note I can't use examples as one of my variable is currentDate function so how to pass currentDate variable via examples.

This is not working. If I don't pass parameters here it works fine. I don't want to define these parameters in karate-config.js file as it is scenario dependent variables.

When I use above in *.js file it works fine but the response body is JSON i can't make a *.js file for that.

1 Answers
Related