Forum Discussion

big's avatar
big
Adept
10 years ago

Inconsistent response for Thread endpoint

Hi,

 

we currently have the following problem:

 

To get the data from a customers community we navigate from Category via Thread to the Messages. Unfortunately the Thread endpoints delivers on page1 other response than on the pages beyond.

 

 

First request (page 1)

.../restapi/vc/boards/id/Fragen/threads?restapi.response_style=view&message_viewer.message_sort_order=thread_descending&message_viewer.topic_sort_order=last_post_date&restapi.session_key=

response structure:

      <threads>
        <thread >
          <messages>
            <linear>
              <message>
              <message>
              <message>

All messages have a date. So we can check which threads are new and we know if we should create a paging action to get all new post according to our check date.

 

Request page 2 (and further)

.../restapi/vc/boards/id/Fragen/threads?restapi.response_style=view&amp;message_viewer.message_sort_order=thread_descending&amp;message_viewer.topic_sort_order=last_post_date&amp;page=2&amp;restapi.session_key=

All parameters are the same. The only different is the page number.

Response structure:

      <threads>
        <thread>
          <messages>
            <linear />

 

In this response there is only the initialpost of the thread and no date of any newer posts. So we can’t do any date-check.

 

Our workaround is to use the endpoints Topics and Replies to get all data within a date to check.

Topics:                 /topics/recent?restapi.response_style=view&amp;message_viewer.message_sort_order=thread_descending&amp;message_viewer.topic_sort_order=last_post_date&amp;restapi.session_key=

Replies:               /replies/recent?restapi.response_style=view&amp;message_viewer.message_sort_order=thread_descending&amp;message_viewer.topic_sort_order=last_post_date&amp;restapi.session_key=

 

But by using this workaround the request count and the runtime is increased by ~40%.

 

Are there any suggestions we can chance?

 

Thanks,

Martin

  • Oh, sorry.  I forgot to mention the nested.page parameter -- set that to 1 when you do your topic message paging and you should start seeing those replies.

  • DougS's avatar
    DougS
    Khoros Oracle

    Hi Martin,

     

    You can try adding the restapi.response_style=replies query parameter to your call (or if you are already using another value for restapi.response_style, you can chain them by adding a comma between values like this: restapi.response_style=view,replies). Adding the value replies to this query parameter tells the API to include the replies in every message.  If you do this for a topic message then you effectively get an entire thread in one response. This page documents the restapi.response_style query parameter: http://community.lithium.com/t5/Community-API/bd-p/developers-rest-api?page=apiresponse#define

     

    If you want to use a different page size for nested replies then for your top-level results, you can include a query parameter named nested.page_size (so, for example, you could use add these query parameters to your call: restapi.response_style=replies&page_size=50&nested.page_size=100).

     

    -Doug

    • big's avatar
      big
      Adept

      Hi Doug,

       

      thanks for your answer. I tried the parameters, but the result is the same like before. On page one there is no problem. All parameters works fine and I got all the information I'm looking for.

       

      But as soon as there a parameter like "page=2" in the request the response only shows the initial post, but no replies or comments.

      If I add the request parameter "restapi.response_style=view,replies", there is an empty replies-tag in response.

       

          <replies>
             <direct type="replies">
                <messages />
                  <count type="int">2</count>
               </direct>
            </replies>

       

      It seems that all other the parameters will be ignored, when there is a page-parameter.

       

      Martin

       

      • DougS's avatar
        DougS
        Khoros Oracle

        Oh, sorry.  I forgot to mention the nested.page parameter -- set that to 1 when you do your topic message paging and you should start seeing those replies.