Forum Discussion

michael-r's avatar
10 years ago

REST API for Message Content of a Featured Thread

Hi there, 

 

I'm just getting my head around REST API & freemarker, so bear with me! :-)

 

I'm looking to call the message content of a thread within a specific board. Specifically, this is for a custom component that is currently looking at the featured topic within a specific board. So I've copied a custom component that a colleague has created, it currently pulls in the the title of the featured topic and the author. Below this, I want a preview of the message content to appear. We are also looking to apply a condition to this so that it only shows 240 characters, as we want to limit the message preview shown within the custom component. 

 

Hope someone can help. 

  • Hi Michael,

     

    The component that your colleague created should already include the thread.id. This is the key to pull the message body as well, e.g. using API v2 and the following LiQL query:

    SELECT body FROM messages WHERE id = 'thread.id'

    You might even want to rewrite the initial component for API v2 and LiQL and pull author, title and body for the specific board identified via board.id in one go like this:

    SELECT author, subject, body 
    FROM messages
    WHERE board.id = 'board.id' AND conversation.featured = 'true'
    ORDER BY post_time DESC
    LIMIT 1

     Try out those two searches in the "API browser" tab in your Studio on stage.

     

    Some further reading:

  • Hi Michael,

     

    The component that your colleague created should already include the thread.id. This is the key to pull the message body as well, e.g. using API v2 and the following LiQL query:

    SELECT body FROM messages WHERE id = 'thread.id'

    You might even want to rewrite the initial component for API v2 and LiQL and pull author, title and body for the specific board identified via board.id in one go like this:

    SELECT author, subject, body 
    FROM messages
    WHERE board.id = 'board.id' AND conversation.featured = 'true'
    ORDER BY post_time DESC
    LIMIT 1

     Try out those two searches in the "API browser" tab in your Studio on stage.

     

    Some further reading: