Forum Discussion

dylan_moberg's avatar
dylan_moberg
Contributor
7 years ago

500 or template model error while trying to make external API request in endpoint.

Hello, I am trying to make an external API request from an endpoint. It is just a simple GET request that returns JSON. I am following the example in the developer documentation https://community.lithium.com/t5/Developer-Documentation/bd-p/dev-doc-portal?section=freemarker#l::%7B%22p%22:%22%2Frefer%2FcontextObjects%22,%22h%22:%22%23httpClientResponse%22%7D 

 

I either receive a 500 error or 

 <p>lithium.coreapi.webui.template.models.HttpClientResponseTemplateModel$Error@6370ead8</p>

 

My code is 

<#assign response=http.client.request("https", "stats.nba.com", "/stats/boxscore").json().get()/>
<#if response?? && response.hasError>
    <p>${response.error}</p>
<#else>
    <p>success</p>
</#if>

 

any help is much appreciated!