# Issue with fetching posts from a channel, limited to timespan

**URL:** https://forum.mattermost.com/t/issue-with-fetching-posts-from-a-channel-limited-to-timespan/13546
**Category:** Troubleshooting
**Created:** [June 11, 2022, 8:50am UTC](https://forum.mattermost.com/t/issue-with-fetching-posts-from-a-channel-limited-to-timespan/13546 "2022-06-11T08:50:16Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![gmmi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/gmmi/32/5588_2.png) [@gmmi](https://forum.mattermost.com/u/gmmi)
#### Post date: [June 11, 2022, 8:50am UTC](https://forum.mattermost.com/t/issue-with-fetching-posts-from-a-channel-limited-to-timespan/13546/1 "2022-06-11T08:50:16Z")

</div>

I am trying to fetch all messages that have been sent to a channel in the last 24 hours. According to the [documentation](https://api.mattermost.com/#operation/GetPostsForChannel) the correct endpoint would be:

```auto
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.):

```auto
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:

```auto
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!

---

<div class="post-metadata">

### Author: ![agriesser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/agriesser/32/5644_2.png) [@agriesser](https://forum.mattermost.com/u/agriesser)
#### Post date: [July 15, 2022, 1:44pm UTC](https://forum.mattermost.com/t/issue-with-fetching-posts-from-a-channel-limited-to-timespan/13546/2 "2022-07-15T13:44:03Z")

</div>

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):

```auto
$ 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):

```auto
$ 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?
