Forum Discussion

iahiqosolutions's avatar
13 years ago

REST API: Retrieve user latest messages only for selected category or board

Hello folks,

 

My question is:

How to I can retrieve user latest messages only for selected category or board using Lithium REST API?

 

I found the following REST API method: users/id/%John_Doe%/topics/latest,

but it seems that it cannot restrict a search scope by specified category or board.

But I want to find topics that specified user posted in the specified category or board.

Any advice?

 

 

10 Replies

  • BoothF's avatar
    BoothF
    Khoros Staff
    13 years ago

    Hi there,

     

    There is a knowledge base article here: that should help achieve exactly this.

     

    Hopefully this helps!

     

    Thanks!

  • Hello Booth,

     

    Unfortunately your example doesn't exactly match my problem.

    As understand you suggest the following:

     

    1. Find all user's tags in the specified location(category or board)
    2. Find all messages that are related for each of these tags
    3. Get details for all find messages separately.

    I guess that this solutions will not work for the following reasons:

    • When user make his post, it is not necessary that he assign some tags to it.
    • How we can find the total number of messages? If we will get all messages for each tags, I guess there are many messages will be duplicated. For example: if message has tags "Tag1" and "Tag2", then this message will be included in both search results(search results for "Tag1" and  search results for "Tag2")
  • AdamN's avatar
    AdamN
    Khoros Oracle
    13 years ago

    My suggestion would be to do a message search via the REST API. If you're not familiar with using our message search REST API, a great way to get started is by using the message search in the UI. From that, you can figure out the parameters you'd like to work with. For example, here's how to get a list of messages that you've posted in the Developer board here on the Lithosphere:

    http://lithosphere.lithium.com/restapi/vc/search/messages?location=Board%3Astudio&author_id=12780

     

    I determined these parameters and sample values by going to the search page and modifying the filters on the left side until I got what I was looking for. For example:

    http://lithosphere.lithium.com/t5/forums/searchpage/tab/message?location=Board%253Astudio&author_id=12780

     

    I hope this helps!

  • Hello AdamN, 

    thank you for your answer!

    As I can see it is exactly solve my problem.

    But I have one addtional question to you:

    Where I can find the full documentation according to parameters of message search via REST API?

     

     

  • jc758's avatar
    jc758
    Advisor
    11 years ago

    Hi !

     

    i know it is an old topic, but i'd like to do the same thing: retreive messages from an author on a particular blog.

     

     

    The problem with ?location=blog-board%3Atest-blog&author_id=5  is that my rest response is empty.
    I need to add the q parameter to make the results appear...

    Moreover, ,n the standard search page result, whereas leaving the search box empty in the Lithosphere return all posts by default, in our community we get the error "Empty search query. Please enter one or more keywords and try again."

     

    Thus this rest call which works perfectly here:

    http://community.lithium.com/restapi/vc/search/messages?location=Board%3Astudio&author_id=12780

     

    would failed on our side.

     

    Is there a param in the admin to specify that the search query can be empty?

    If not , is there a wildcard i can set in the url for the q param?

     

    Regards

     

    JC

     

  • jc758's avatar
    jc758
    Advisor
    11 years ago

    Hi ,

     

    thanx for the reply, but i've got no problem with the location (but you're syntax is better than the other ;) )....

     

    My problem is that i've got no result if i don't specify the q parameter :

     

    search/messages?q=test&board_id=blog-dev&author_id=5&restapi.response_style=view

    will return results

     

    search/messages?board_id=blog-dev&author_id=5&restapi.response_style=view

    return an empty response :

    <response status="success">
    <messages/>
    </response>

     regards

    JC

     

     

     

  • samudhraa's avatar
    samudhraa
    Expert
    11 years ago

    Hi jc758,

     

    If you want to get only the root topic messages (and you do not want the comments ) , you can add this value for q

    search/messages?q=is_root:true&board_id=blog-dev&author_id=5&restapi.response_style=view

     

     

    This would include only the root message , and would also serve as a value to the "q" parameter , while including all posts.

     

    Hope that helps.

     

    Thanks,

    Sam

     

  • jc758's avatar
    jc758
    Advisor
    11 years ago

    Hi Sam!

     

    thanks, that's what i was looking for!

     

    blogs/id/blog-dev/search/messages?q=is_root:true&author_id=5&restapi.format_detail=full_list_element&restapi.response_style=view

    do the trick now ;)

     

    regards

     

    JC

  • HaidongG's avatar
    HaidongG
    Lithium Alumni (Retired)
    11 years ago

    Hi JC,

     

    Search without "q=" is as known as blank search. The community disabled that feature by default. Lithium Support can help you enable this feature from backend. After that you will see results from   /search/messages  (without any parameters)

     

    please keep in mind that it will also affect the community search, i.e. when someone hits the "search" button without any input, he will be able to see some result in search page.