Ask a Question

How can I send HTTP/ Rest post request via Groovy script?

Rhonda_Ward
Occasional Contributor

How can I send HTTP/ Rest post request via Groovy script?

How can I send HTTP/ Rest post request via Groovy script?

Can someone please provide me the sample code?
6 REPLIES 6
SmartBear_Suppo
SmartBear Alumni (Retired)

Hello,

yes, you should be able to simply use testRunner context variable like:

testRunner.runTestStepByName("my-test-step-name")

Entire API is available here - http://www.soapui.org/apidocs/com/eviwa ... unner.html
but for simple existing examples you can refer to http://www.soapui.org/Scripting-Propert ... ricks.html

Hope this helps!

Vladimir,
SmartBear Sweden

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Rhonda_Ward
Occasional Contributor

Sorry I was not clear in my post. I want to construct HTTP post request using groovy and then execute it. Can you please provide me the example?

Between, I did try HTTPBuilder class but was not able to execute the script successfully.
SmartBear_Suppo
SmartBear Alumni (Retired)

Hi,

For this you would need to use a third party http library for Java or Groovy (HTTPBuilder being one alternative). For support on using a third party library, please refer to that library's support options.

Please note that soapUI currently does not support the Grape dependency loader mechanism. Any external library (and its dependencies) will have to be manually placed in the bin\ext directory of your soapUI installation.

Regards,
Dain
SmartBear Sweden

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

 as this is an old post, is this still the case or is there now a means of doing this without using 3rd party libraries?

nmrao
Champion Level 2

You want to put your use case? when there is readily available steps available, why do you need to use groovy to do this?


Regards,
Rao.

I'm using ServiceV and creating virts (then using VirtServer)

 

Suppose we have a service (api or soap) that takes a request then in formulating the response invokes another service for data to include within its response

 

in creating a virt to simulate that behavior we can create some datasets to mimic the secondary request response data which we would then have to maintain to ensure that data's relevance as the actual response data varies massively

 

or we could send an actual request to that secondary service then use the response data in our virts response thereby removing the dependency on that data maintenance

 

being able to send requests onto other services from virts would be a useful feature in my opinion, as there doesn't seem to be a direct way of doing this the next logical step would be to do this via groovy

 

regards

Mike

cancel
Showing results for 
Search instead for 
Did you mean: