Forum Discussion

KPNOnline's avatar
KPNOnline
Mentor
10 years ago

Get local json asset in Freemarker

How to get content of a local (json) asset?

 

For external assets I could do something like this:

 

<#assign response =  http.client.request("qszwf76546.stage.lithium.com/html/assets/header-settings.json").json() />

But how do I grab a local assets content and parse it as a freemarker hash?

 

Thanks

  • Closing the loop here. You can't use http.client with Lithium domain.

3 Replies

  • KPNOnline's avatar
    KPNOnline
    Mentor
    10 years ago

    Hi VarunGrazitti

     

    Thanks for the reply, but the real question was how to get the local asset in Freemarker. After I get it I can parse it.. But somehow it will not grab a local assets content.

     

    I tried it inside a component as well with an endpoint:

     

    <#assign response = http.client.request("http://qszwf76546.stage.lithium.com/html/assets/header-settings.json").json().get() />

    ${response}

     

    Although the repsonse variable gives back a string in the Endpoint, I cannot fetch the content.

     

    The only response it has is:"lithium.coreapi.webui.template.models.HttpClientResponseTemplateModel@452d22f"

     

    ${response.content} triggers an error (with .json() or without)

     

    How to get the file in Freemarker OR the content in an endpoint?

     

    Thanks again!

     

     

  • OlivierS's avatar
    OlivierS
    Lithium Alumni (Retired)
    10 years ago

    Closing the loop here. You can't use http.client with Lithium domain.