Karate Automation: How to Set Dynamic Path for a URL, from a json data

Viewed 877

From Feature file 1, i am reading the content of a json file and passing it to the serverpost.Feature

feature file 1

* def output = read('output.json')
* def result = call read('serverpost.feature') output

In feature file 2, i am trying to set the Path as TC_ID and request body as BODY from the json data.

However, i am not able to set the path using the below feature. Please assist

Feature file 2

Given path '#(TC_ID)'
Given url 'http://myappurl.com:8080/mytestapp/Servers/Data/uploadServer/'
And request { some: '#(BODY)' }     #### Here i am able to get the BODY data from JSON
When method post
Then status 200
1 Answers

The '#(foo)' notation applies only to JSON, XML or the right-hand-side of a match statement.

Please use it like a normal JS expression:

Given path TC_ID

or

Given path output.TC_ID

Related