Forum Discussion

luk's avatar
luk
Boss
7 years ago

[Bug] REST API v1 /topics calls return wrong count

I recently ran into issues when trying to build a custom pagination component that was sometimes trying to get the total amount of topics/threads via /threads and other times via /topics, the results were inconsistent. After some digging it seems, that all /topics calls for REST API v1 return a wrong count for the total amount of threads/topics. In the example that follows, the correct count is 17, but /topics or /topics/count both return 18.

 

this is a call to /topics on a tkb board node, obviously the total amount of messages/topics is 17 (as seen in the "messages": [] property of the response, nonetheless the "count" property of the response says 18, a call to /topics/count returns 18 as well.

This is a call to /threads on the same node (any url params are exactly the same!): as can be seen there is a) no "count" returned, which is inconsistent BTW =) and b) the "thread": [] property holds again 17 items, a call to /threads/count also returns 17

When doing the same via API v2 the correct count/size of items is returned as well: 17

 

I'm not sure how long this is an issue, anybody had the same issue? Or maybe DougS knows about that or even has a good explanation why this is?

  • luk- We had the same data discrepancy issue between API V1 and API V2. We get it fixed from lithium support. You should use API V2 until the issue get resolved by lithium support.

    • luk's avatar
      luk
      Boss
      Yeah, doing that usually, but have a case where that's not possible and then I need to fix the issue by subtracting 1 from the count, which is kind of awkward =)...
      • luk- Not recommended but if there is no other option left you can use this. As in our case too, We were getting API V1 count one less than API V2.  What is the case which won't let you use API V2?