how to extract "Rest Request properties" via groovy Script from Rest Test step
I need help in trying to extract the Rest Request Properties associated with a Rest Request test step in ReadyAPI via Groovy Script.
Scenario -
want to extract the Resource property listed under Rest Request Properties. The Resource path property available under Rest request property then needs to be parameterized so that it can be updated at run time by using a project parameter and support two or more versions of code base by modifying one of the path parameters at run time. I have more than 30 APIs so cant go manually and change the Resource path to a parameterized.
Using groovy script I am able to extract the custom parameters but not able to extract the Rest Request properties.
Can someone please help in guiding with a solution or pointing to an existing answer.
I did found lot of questions asked by other users on extracting Custom properties from the request but could not find anything related to Rest Request properties.
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())