Issue with fetching posts from a channel, limited to timespan

I am trying to fetch all messages that have been sent to a channel in the last 24 hours. According to the documentation the correct endpoint would be:

https://mattermost.mydomain.tld/api/v4/channels/mychannelid/posts

The explanation for the since-parameter says:

Provide a non-zero value in Unix time milliseconds to select posts modified after that time

So from my understanding I would need to issue a request to the following URL to fetch the range of posts I want (in this case all posts that have been made since June 10th, 12 p.m.):

https://mattermost.mydomain.tld/api/v4/channels/mychannelid/posts?since=1654855200000

However this does not return any results at all. I suspected this might be because of an error in the documentation, and instead that I would need to use seconds, not miliseconds:

https://mattermost.mydomain.tld/api/v4/channels/mychannelid/posts?since=1654855200

This time I got the first 1000 results since the beginning of the channel history. But from my understanding this should result in all posts that have been made since that date, not until that date. Does anyone have an idea what my mistake could be?

Unfortunately I don’t have access to the server-side logfiles. I am convinced that I am missing something obvious here, but I can’t for the life of me find the issue on my own. Thank you for your help!

Hi gmmi,

this works for me here on 7.0.1.
I’m querying all posts in the channel and print out the “create_at” attribute for them (most recent posting at the top):

$ curl -sH 'Authorization: Bearer top-secret' https://mydomain.com/api/v4/channels/kx7h9afpttry88oq3dzwnosa1e/posts  | jq -r .posts[].create_at | sort -r
1657892315132
1657892181938
1657891087270
1657891053150
1657108111384
1657107512536

And when I add the ?since parameter, it filters them out correctly, so when I use ?since=1657891087270 I will only see the two most recent messages (the filter is exclusive):

$ curl -sH 'Authorization: Bearer top-secret' https://mydomain.com/api/v4/channels/kx7h9afpttry88oq3dzwnosa1e/posts?since=1657891087270  | jq -r .posts[].create_at | sort -r
1657892315132
1657892181938

How does this simple example look like on your installation and what Mattermost version are you using?