Forum Discussion

Flexerian's avatar
Flexerian
Contributor
6 years ago

http.client.request error unexpected execution exception

Hi

I'm using the following to make an http request  (endpoints)

 

<#assign response = http.client.request("<a href="https://domain.com/?action=list_items").get()/" target="_blank">https://domain.com/?action=list_items").get()/</a>>
<#if response.hasError>
${response.error.message}
</#if>

 

 

domain.com is in the approved domain list and hitting the url returns the expected json.   

The error when testing it is "unexpected execution exception" . It was working earlier with no changes, this is a staging environment. 

Any help appreciated it.

 

  • EDIT: I stand corrected, I don't think you passed an HTML link =)...I think Lithium messed up with the v2 editor...it parses links in PRE/CODE blocks and they are then displayed as HTML... ping SuzieH could you forward that issue to the appropriate team? There is another issue as well, editing a post removes ALL closing tags in FreeMarker code...basically have to redo code blocks each time you edit a post...


    Flexerian That is never going to work like that you are passing an entire HTML link-tag as a URL parameter to the http.client.

    If you add a <#attempt><#recover></#attempt> block around your code you might get better error messages, not guaranteed though... for now, try this:

     

     

    <#attempt>
        <#assign response = http.client.request('...https...domain.com/?action=list_items').get() />
        
        <#if (response.content)?has_content>
            Response had content!
        </#if>
        
        <#if response.hasError>
            ${response.error.message}
        </#if>
        
    <#recover>
        Recovered from error: ${.error}
    </#attempt>

     

     

     

     

     

    • SuzieH's avatar
      SuzieH
      Khoros Alumni (Retired)

      Thank you luk . I'll be passing this on to the Product Manger for the Editor v2 feature. ChetnaS - please see luk's comment above. Additionally, I noticed issues with XML code samples in PRE tags - so we definitely have some work to do here.