Forum Discussion

dou's avatar
New Contributor
8 years ago

How to write a groovy script for a REST project



I am a beginner with groovy script and Rest project.


I read some RESt and groovy script blog, and subject but, i don't know how to begin.


I know :

- how to import a REST project with SOAP UI

- to execute a request, we need to add a Resource, a method, and/or a path param, request param and/or a body.


So how to add all theses parameters correctly with groovy script ?

Is there some kind of Library ? API ?


Best Regards and thanks for your help.



  • Looks I missed the conversations below.

    You mentioned, "Yes. I need to know how to build and execute Rest using groovy"

    You may need to spend time to understand first how things works.

    If there is a ladder, there are steps, climb one by one. Can't reach from first step to top step in Single step.

    For every thing there will be a learning curve.

    I could not understand that If you just wanted to do it in groovy, then why you Ready API was choosen.

8 Replies

    • dou's avatar
      New Contributor

      Is there a reason that you have to use Groovy script?


      Yes. I need to know how to build/ execute a Rest Request using groovy script.


      Have you seen the following tutorial?

      No, i didn't see it. Thank you !


      I have found this link :


      Do you know how can i add Rest parameter QUERY, TEMPLATE, HEADER, MATRIX, PLAIN with groovy ?

      • Radford's avatar
        Super Contributor

        Sorry, I'm not sure if I'm the right person to help as I don't have detailed knowledge of building and executing REST requests via Groovy (I tend to stick to using the built in test steps and only dropping into Groovy only when I need extra functionality).


        A quick look at the REST test step shows its a RestTestRequestStep. This class has various methods for adding parameters, though I have not had to do this myself so can not comment further. In case I mis-understood your last message, if you are wanting to set already existing poperties this page may help.


        Hopefully, somebody else with more detailed knowleddge of building REST requests via Groovy can help.

  • nmrao's avatar
    Champion Level 3
    Why reinventing the wheel being a beginner. You may start using the existing feature, once you become familiar to it, you automatically do things on your own.

    I suggest you to get familiar with tool by spending time, exploring it while having the privilege to enjoy the existing features.

    Or is there any constraint that you have so that things to need in such an order? This is just to know your use case.

    You may use the link provided by Radford.

    We have a great community, you can always come back and post your specific questions. And there are may good people will help the community.

    Have good time.