Forum Discussion

omygoodness's avatar
8 years ago

Absolute URL from view_href

Is it possible to get absolute URL from such query?
SELECT * FROM messages WHERE kudos.sum(weight) > 0 AND author.id='3' ORDER BY kudos.sum(weight) DESC

 

I know it is possible with API v 1 and can be achieved like this:

&restapi.response_style=view

 

but in this case I need to use API v 2 and I have no idea what to do.

  • omygoodness - Yes, check this out here

     

    You need to use this -

     

    <#assign labels = rest(apiVersion, "/search?q=" + labelsQuery?url + "&restapi.response_style=view").data.items![] />

    I hope this helps. 

    • omygoodness's avatar
      omygoodness
      Mentor

      VarunGrazitti

      Unfortunately it is not working for me.

       

      I did something like this:

       

      <#assign apiVersion = "2.0"/>
      <#assign topKudosQuery = "SELECT * FROM messages WHERE kudos.sum(weight) > 0 AND author.id='3' ORDER BY kudos.sum(weight) DESC" />
      <#assign topKudos = rest(apiVersion, "/search?q=" + topKudosQuery?url + "&restapi.response_style=view").data.items![] />
      
      <#list topKudos as x>
          <div>
              data: ${x.post_time?datetime?string('dd-MM-yyyy HH:mm')}<br>
              tytuł: ${x.subject}<br>
              adres: ${x.view_href}<br>
              ilość wyświetleń: ${x.metrics.views}<br>
              treść: ${x.body?replace("<[^>]*>", "", "r")?replace("&nbsp;", " ", "r")}<br>
              lajki: ${x.kudos.sum.weight}
          </div><br><br>
      
      </#list>

      When I am trying to use: ${x.view_href} I get url like this: /t5/BlaBla/BlaBla/m-p/1896#M1 and when I am trying to use code ${x.@view_href} I get error:

       

      The following has evaluated to null or missing:
      ==> x.@view_href  [in template "latest-kudos-test.ftl" at line 13, column 18]