Search code examples
restyammer

How can I know what the latest Yammer message using the REST Api?


I have a client that get all company messages and according to the documentation we should use this call, where latestid is a number like : 792425364

https://www.yammer.com/api/v1/messages.json?newer_than=<latestid>

When I inspect the results I get:

  1. Not only messages but also other entries
  2. Messages, but I cannot see any order

So I guess I am looking for a sample that first fetches "all" messages (without the newer_than parameter) and in a second iteration uses the "latest" id from the previously retrieved list.


Solution

  • Thanks to @GouravChawla I was forced to take a closer look.

    The JSON that is return by the endpoint

    https://www.yammer.com/api/v1/messages.json
    

    Contains a "messages" property. The messages in this array are ordered by id, at least so it appears at first look.

    When I use

    https://www.yammer.com/api/v1/messages.json?newer_than=<latestid>;
    

    And provide the message id of the first entry of the first call, I get zero results. If I provide the message id of the second entry I get one result, that is the one with the message id of the first entry of the first call.