Forum Discussion

michaelaar's avatar
michaelaar
Contributor
9 years ago

Trying to create API call that returns list of blog posts filtered by specific tag value

Hi,

I am trying to create a rest api call that returns a list of blog posts related to a specific blog board ID, but filtered to only blogs that have a specific tag applied to them.

 

For example, the first part of the URL returns the 5 most recent blogs in category defined by stated ID:

http://community.lithium.com/community-name/restapi/vc/blogs/id/video_cards/topics/recent?page_size=5

I would like to apply a filter on top of that, which limits the returned blogs to only those that have a specific tag value.

I have tried applying the tagging/for/tags/text/[tag_text] filter but cannot get it to work.

Any help on correct syntax would be much appreciated.

Thanks,

Michael

  • PaoloT's avatar
    PaoloT
    Lithium Alumni (Retired)

    Hi michaelaar

     

    have you tried with LiQL ?

     

    SELECT * FROM messages WHERE depth=0 AND conversation.style = "blog" AND board.id = "BLOGID" AND tags.text = 'FOOBAR' 

    More documentation here

     

    Hope it helps!

  • Hi,

    Thanks for your response.

    Trying to do this using a URL, if possible.

    Regards,

    Michael

    • irach15's avatar
      irach15
      Maven

      michaelaar,

      did you do it with url?

      I'm trying to do similar and got to issue, 

      depth=0

      not getting through...

      https://api.lithium.com/community/2.0/tenantID/search?q=select id, subject, body, board.id, board.title, tags, labels, view_href, post_time_friendly, metrics, tags.count(*), labels.count(*) FROM messages WHERE depth=0 AND board.id ='yourBoarID' ORDER BY post_time DESC&client-id=yourClientID&&api.pretty_print=true

      if no depth=0 or depth>0, it works fine. But I need depth=0, only top messages, no replies., and only tkb articles...

      Any ideas? PaoloT?

      • PaoloT's avatar
        PaoloT
        Lithium Alumni (Retired)

        Hi irach15

         

        maybe it's a stupid question, but you seem to be passing a board id in your filters 

        AND board.id ='yourBoarID'

        so I would expect only messages from that board's interaction style to be returned. The depth filter should work fine too, it could help if you can share the error message you get?

         

        To my knowledge the call should return TKB articles in general, so if it's not doing that I suggest opening a Support Case with our support department for them to investigate.

         

        michaelaar - to make a call via HTTPS, please familiarize with the documentation available here as a starting point. Let us know how it goes!

         

        hope it helps