Forum Discussion

janh's avatar
janh
Mentor
12 years ago

Retrieving the Tag ID through REST

Hi guys,

 

I appear to be in bit of a bind. Currently I'm modifying the Tag View Page to use a customized thread list appearance but I need to create 'View All' link for sections 'Recently Tagged' and 'Most Tagged', however the link requires the tag ID to be passed as a parameter to the Tag Detail Page if I want to get the full list of Recently Tagged or Mostly Tagged threads.

 

So here is how I grab the tag element from the Tag View Page

 

<#assign tag = webuisupport.path.parameters.name.get("tag-id")/>

 

If I print out the tag value on to a page, it would look like this:

 

StandardTextTag[tagText=Clienterror,id=TextTagByUidRef[uid=15,hashCode=1737709434],canonicalDisplayRef=TextTagByTextRef[tagText=Clienterror]]

 

So if I use ${tag.tagText} I get "Clienterror" but how do I go about getting the ID of the tag I'm viewing in that page? Both ${tag.id} and  ${tag.id.uid} node return with "Expression is undefined" errors, after searching through the documentation I haven't come across any way of getting this node value

 

Thanks!

 

  • To get the ID of a tag via the REST API given the tag text, you can use the following call:

    /restapi/vc/tagging/tags/text/tagname

    For example:

    http://lithosphere.lithium.com/restapi/vc/tagging/tags/text/rest%20api

     

    In the response, you'll see an "id" element, which tells you the ID of the tag. For example:

    <response status="success">
      <tag type="tag" href="/tagging/tags/id/720">
        <id type="int">720</id>
        <text type="string">rest api</text>
      </tag>
    </response>

     

  • AdamN's avatar
    AdamN
    Khoros Oracle

    To get the ID of a tag via the REST API given the tag text, you can use the following call:

    /restapi/vc/tagging/tags/text/tagname

    For example:

    http://lithosphere.lithium.com/restapi/vc/tagging/tags/text/rest%20api

     

    In the response, you'll see an "id" element, which tells you the ID of the tag. For example:

    <response status="success">
      <tag type="tag" href="/tagging/tags/id/720">
        <id type="int">720</id>
        <text type="string">rest api</text>
      </tag>
    </response>