How I can call rest web service on click of btn returning json format, need show values out of that json format in few fields on the form?

    CommentAdd your comment...

    1 answer


      Hey Leena, you can call a REST service directly from the form using JavaScript that executes when the button is clicked. A google search will yield many examples on how to call REST services from JavaScript.

      However, the way we typically do this is to create a Dynamic Data Service on Transaction Manager that accesses the REST service and returns the data to the form. These services need to be coded in Groovy and will require some programming skills.There is a bunch of documentation available on the Avoka Community that deals with this, E.g.:

      In Transact 5, developers can build these Groovy services in an IDE of their choice - more info.

      1. Ben Warner

        Were you able to get this working Leena?

      2. leena

        Hi Ben,

        I am trying to call REST by creating a Dynamic Data Service on Transaction Manager that accesses the REST service and returns the data to the form. I am using the following line of codes::

        import net.sf.json.*;

        import net.sf.json.xml.*;

        import com.avoka.core.groovy.GroovyLogger as logger


        import com.avoka.component.http.GetRequest

        import groovy.json.JsonBuilder

        def username = "subhojit_bose_ibm"
        def password = "subhojit_bose_ibm"
        def params = [:]
        //def params.meternumber = meternumber

        // execute GET request and return a HttpResponse object  
        def response = new GetRequest('http://esp-rip-nonprod-vip:8044/rest/meter/10M7413')
              .setBasicAuth(username, password)

        logger.info "execute: "

        But while running and checking groovy script logs, I am ablr to see unknown host error. Could any body help or suggest the reason and the solution.Can we raise ticket with Avoka?

      3. Ben Warner

        Hey Leena, the unknown host error would suggest that the server with the REST service is not accessible from the Avoka server. This is a network issue within your on-premise environment and not something that Avoka would be able to resolve. I suggest you speak with your IT team or the owner of the REST service to see if they can resolve the networking issue in the first instance.

      4. leena

        ok Thanks Ben!!

      5. Ramya Tata


        Were you able to make this work? I am trying a similar approach to call a REST Webservice using Transaction Manager. I keep getting below error:

        com.avoka.core.groovy.GroovyScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
        Script1.groovy: 11: unable to resolve class com.avoka.component.http.GetRequest
         @ line 11, column 1.
           import com.avoka.component.http.GetRequest

        The Avoka TM Version we are using is 4.0.7
        Build Number 37608
        Number of Active Forms: 8

        Which Avoka Version are you using?


      6. Ben Warner

        Hey Ramya, GetRequest was added in version 4.2.0. Please see my response to your Q&A query for more details:

        What is the best approach to create a Client to call a REST Webservice? Using Transaction Manager or Java Script in Composer?

        Kind regards, Ben.

      CommentAdd your comment...