Forum Discussion

cjdinger's avatar
cjdinger
Leader
9 years ago

Fully qualified view_href not coming through in HTTPS endpoint

I'm creating an Endpoint that simulates an RSS feed for featured topics in certain board/categories.  Using the v2 API, I'm using the message.view_href property to populate the <link> field.  That works perfect when the endpoint is called using HTTP.  But when using HTTPS, the view_href field is missing the site address, and returning just the relative URL.

 

For now, I've kluged it so that I append the base site URL when using https.  But...why?  What am I missing?

 

Here's my code.

 

<?xml version="1.0" encoding="UTF-8"?>
<#-- Endpoint to serve the most recent featured topics -->
<#-- Specify either category= OR board= on URL         -->
<#assign category = http.request.parameters.name.get("category", "sas_programming")/>
<#assign board = http.request.parameters.name.get("board", "")/>
<#assign size= http.request.parameters.name.get("size", "5")/>
<#assign root=""/>
 <#if (http.request.ssl == true)>
    <#assign root="https://communities.sas.com"/>
</#if>
<#if (board)?has_content>
<#assign messages = rest("2.0", "/search?q=" + 
   "SELECT * FROM messages WHERE depth=0 AND board.id = '${board}' 
     and conversation.featured=true ORDER BY post_time DESC LIMIT ${size}"?url 
     )/>
<#else>
  <#assign messages = rest("2.0", "/search?q=" + 
     "SELECT * FROM messages WHERE depth=0 AND category.id = '${category}' 
      and conversation.featured=true ORDER BY post_time DESC LIMIT ${size}"?url 
     )/>
</#if>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
<channel>
 <title>Featured content from SAS Support Communities</title>
 <link>https://communities.sas.com</link>
 <description>These featured topics are the most recent from SAS Support Communities</description>
  <#if messages.data.items?has_content>
  <#list messages.data.items as message> 
  <item>
   <title>${message.subject}</title>
    <link>${root}${message.view_href}</link>
    <description>${message.body?html}</description>
    <guid>${root}${message.view_href}</guid>
    <pubDate>${message.post_time?datetime?string["EEE, MMM dd yyyy HH:mm:ss +0000"]}</pubDate>
  </item>
  </#list>
  </#if>
</channel>
</rss>

Example endpoint call:

https://communities.sas.com/kntur85557/plugins/custom/sasinstitute/sasinstitute/featured-rss?board=sas_eg

 

Thanks for any tips,

Chris

  • This looks like a bug, but we still need to investigate this further. It looks like you have a good workaround in place. Please file a support case if you would like to get status updates on when this gets fixed.

     

    -Doug

3 Replies

  • DougS's avatar
    DougS
    Khoros Oracle
    9 years ago

    This looks like a bug, but we still need to investigate this further. It looks like you have a good workaround in place. Please file a support case if you would like to get status updates on when this gets fixed.

     

    -Doug

  • DougS's avatar
    DougS
    Khoros Oracle
    8 years ago

    After looking at this issue more closely, it looks like we have always made the view_href return a relative URL when a REST V2 call is made via Freemarker (whether it is made via a component or via an endpoint). The reason we designed it that way was because some communities have multiple hostnames (not a common configuration, but we have a few) and we wanted customers to choose a hostname to put in front of the view_href URLs. I tested this out and it the view_href URLs are relative whether an endpoint is called over HTTP or over  HTTPS, so (at least now) there is not a discrepancy between HTTP and HTTPS.

     

    -Doug