how to extract "Rest Request properties" via groovy Script from Rest Test step
- 7 years ago
Well one of the things you requested was how to extract the REST Request properties.
You can do this in a groovy script in the RequestFilter.filterRequest event handler
Now, you say you want to parameterize the resource path. You have 30 APIs. You mean in https://xxx.xxx.xxx.xxx:xxxxx form? It might make sense to use the Environment capability to switch between APIs.
You can use the Environement to set the custom project property for the resource of that API. Then in Groovy use the property expansion to set the resource My link above "gets" the resource.
From the context module you probably can use setProperty. You can also drill down to the test case to set the request when everything is all ready. I add stuff to the body of the request and do something the following in a Groovy test step (not the event handler)
def json = … def restRequest = testRunner.testCase.getTestStepByName(“my test step name“); // Set the json for the test step request restRequest.setPropertyValue('Request', json.toString())