Forum Discussion

navya_0204's avatar
6 years ago

How to write a rest call to retrieve information from a blog page and forum page

I am trying to create a custom component to retrieve articles based on labels but not sure how to design the rest call.

  • Hi navya_0204,

    use APIv2 to achieve this:

    SELECT * FROM messages WHERE conversation.style = 'blog' AND labels.text IN ('label_1', 'label_2')

     

    More about APIv2 can be found here.

     

    Best regard

    Christian

    • navya_0204's avatar
      navya_0204
      Helper

      Here is our approach towards the retrieving labels from the TKB Page

      <#assign labellist = restadmin("/boards/id/${coreNode.id}/labels?page_size=1000")/>

      and want to implement the same approach to implement label filter for the forum and blog page.

      Can anyone let me know how to retrieve the labels for blog page also for the forum page.

      • cike's avatar
        cike
        Champion

        navya_0204  - With the API call you mentioned above you're able to get the labels for each type of board, no matter what type of conversation it is: If your coreNode is of type blog, you get labels for the blog node and so on.

        If you want to get the labels for all nodes within a location (e.g. category) you can do something similar to this:

        1. Get all board IDs for your category (With this you have IDs for all your nodes, blogs, TKBs, ...)
        2. Loop through the list of IDs and use the API call above to get labels for each node.
        3. Aggregate all API responses (label lists) into one, so you have a complete list of all your labels.

        While looping through elements and sending multiple API requests could be a time consuming task, I would assume using an endpoint to build the label list and request the endpoint from your custom component.