Rocket Modern Experience (formerly LegaSuite)

 View Only
  • 1.  How to call an API from a Web Page with parameters

    PARTNER
    Posted 05-04-2023 10:18

    Hello,

    I would like to call an API from a Web Page that uses parameters. Could anyone please give me a sample?

    Thanking you in advance
    George



    ------------------------------
    George Milisis
    Syntax Information Technology Inc.
    Athens GR
    ------------------------------


  • 2.  RE: How to call an API from a Web Page with parameters
    Best Answer

    ROCKETEER
    Posted 05-04-2023 10:27

    Hi George,

    What kind of service do you want to call?

    In recent versions of our product (10.1.3 and up) the workbench will contain a number of example scripts for use of MFA (Multi Factor Authentication) servers.
    These contain examples of POST service REST calls where arguments are passed in the body, and also  GET calls. To find these: create a new web project in a recent version of the workbench, find script function file 'MFAFunctions'  and look for the HttpRequestSend() calls.

    Passing arguments to a GET call typically can be done using a question mark and the arguments on the URL. 
    For instance: https://something.mydomain.com/myservice?argument1=one&argument2=two

    For a POST call the contents is usually in the body, which can be in different formats, for example JSON or XML.

    Hope this helps,
    Regards,



    ------------------------------
    Roger van Valen
    Senior manager, software engineering
    Rocket Software
    Dordrecht, The Netherlands
    ------------------------------



  • 3.  RE: How to call an API from a Web Page with parameters

    ROCKETEER
    Posted 05-04-2023 10:30

    Hi George,

    Another more convenient way would be to create a service definition in the workbenchfirst.

    After creating a service definition to call a service (this can be a REST service, SOAP service, Database service or what have you), you can drag and drop this service from the 'services'  view onto your web page directly. The Web builder will create a button to onvoke the service and also input and output fields for the input and result of the service.

    Regards,
    Roger.



    ------------------------------
    Roger van Valen
    Senior manager, software engineering
    Rocket Software
    Dordrecht, The Netherlands
    ------------------------------



  • 4.  RE: How to call an API from a Web Page with parameters

    PARTNER
    Posted 05-04-2023 11:11

    In this case the service will be GET, I suppose even if I provide either necessary input?



    ------------------------------
    George Milisis
    Syntax Information Technology Inc.
    Athens GR
    ------------------------------



  • 5.  RE: How to call an API from a Web Page with parameters

    ROCKETEER
    Posted 05-08-2023 02:18

    Hi George,

    In a GET http request usually the parameters are passed on the URL.
    Some may be passed through the HTTP(S) headers, for instance authentication is often passed that way.

    This will work both in a service object or in the HttpRequestSend() function calls.

    If you need help on a specific project or service/API call that you cannot share in public, feel free to create a support case so our tech support can assist you with this.

    Regards,



    ------------------------------
    Roger van Valen
    Senior manager, software engineering
    Rocket Software
    Dordrecht, The Netherlands
    ------------------------------