1
0
-1

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

    1.  
      1
      0
      -1

      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)
              .execute()

        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!!

      CommentAdd your comment...