Forum Discussion

mfeltscher's avatar
11 years ago

Using Third-party API in custom component

Hi there.

 

I'm currently working on a custom component where I have to load data from a third-party API. Is there any way this can be done using FreeMarker without the need of an endpoint?

 

I'm asking because I found this comment stating that the http.client FreeMarker Context Object is not available inside a custom component but it is planned to allow this in the future. First tests on my side show that it is not at this point. 

 

Using a third-party API to fetch information inside a custom component is something I have to be able to do to fulfill our customers requirements.

 

Any ideas?

 

Thanks for your help!

  • NicoB's avatar
    NicoB
    11 years ago

    Hi mfeltscher 

    Yes, you can get in touch with our Lithium representative for your organization which will begin the Professional Services engagement.

    Unfortunately I do not have an ETA for when and if the http.client will be made available to custom components.

     

    Thanks,

     

    Nico

  • Unfortunately at the moment external web services can only be accessed within endpoints, and endpoints cannot be accessed by custom components, and so it is not possible to access an external web service inside custom components. I suggest you read this thread for more details:

    http://community.lithium.com/t5/Developers-Discussion/How-do-you-call-an-endpoint-from-freemarker/m-p/97464

     

    The only work around I am aware of is to use JavaScript (AJAX) - you can use it to access the third-party API directly, or alternatively use a custom end-point as a proxy.

     

    There's a pretty good example of this here:

    http://community.lithium.com/t5/Developers-Knowledge-Base/Using-the-http-client-Context-Object-to-Integrate-with-a-Third/ta-p/91640

    • NicoB's avatar
      NicoB
      Lithium Alumni (Retired)

      Hi @mfeltscher

      indeed it's not possible to use http.client in a component so as Nathan was saying the only option is by using an endpoint but this leaves the only option of accessing such external data on the client side.

      If this is a show stopper issue for you you might want to engage with our Professional Services team which should be able to find a solution to tackle this requirement.

      A solution could consist of making the data extracted from the external service, available as a Freemarker context variable.

       

       

      Thanks,

      Nico

      • mfeltscher's avatar
        mfeltscher
        Expert

        Hi NicoB 

         

        This really is a show stopper issue for us. Using an AJAX call to get this information does not work on clients which have JavaScript disabled. The data we are trying to load is crucial and has to be part of the response, otherwise the whole custom component is unusable.

         

        How do I contact your Professional Services team? Should I talk to our Lithium contact about it?

         

        Do you see any chance the http.client FreeMarker Context Object will be available in custom templates soon or at least it's possible to use endpoints inside custom templates as stated here?

         

         

        Thanks,

        Moreno