cancel
Showing results for 
Search instead for 
Did you mean: 

change the request type from GET to POST using groovy in soap ui

Contributor

change the request type from GET to POST using groovy in soap ui

I am trying a scenario where I am dynamically creating a project,suite and test case in soap ui.

I am able to create the project,tc and request but in soap ui by default rest request is loading as GET request.

 

Can any one help me on how to change the request method from GET to POST using groovy?

1 REPLY 1
Super Contributor

Re: change the request type from GET to POST using groovy in soap ui

import com.eviware.soapui.impl.rest.RestResource
import com.eviware.soapui.impl.rest.RestRequest
import com.eviware.soapui.impl.rest.RestMethod
import com.eviware.soapui.impl.rest.RestService
import com.eviware.soapui.impl.rest.RestRequestInterface

RestService restService = testRunner.testCase.testSuite.project.getInterfaceList()[0]
RestResource resource = restService.getOperationByName( 'ResourceName' )
//resource = resource.getChildResourceByName( 'ChildResourceName' )
RestMethod method = resource.getRestMethodByName('MethodName')
method.setMethod(RestRequestInterface.HttpMethod.POST)
log.info method.getMethod()

http://www.soapui.org/apidocs/com/eviware/soapui/impl/rest/RestMethod.html#setMethod-com.eviware.soa...

New Here?
Join us and watch the welcome video:
6 / 7 API Testing Mistakes Video
Top Kudoed Authors
Top Kudoed Posts