I can't get before_id to work in the API

Hello,

This is probably a problem between the chair and the keyboard, but I can’t get ‘before_id’ to work in the API

I’m doing this (in Powershell):

$headers = @{                                                                                                         
    "Authorization" = "Bearer $Token"                                                                                           
    "Content-Type"  = "application/json" 
}

then:

Invoke-RestMethod -Uri "https://micro.blog/posts/mattypenny?before_id=54031284" -Method Get -Headers $headers | select -expand items

…and I’m expecting that to return posts before the post with that id, but it’s just returning the most recent posts

The ‘count’ clause, by contrast, does seem to have an impact. If I do this:

Invoke-RestMethod -Uri "https://micro.blog/posts/mattypenny?count=2" -Method Get -Headers $headers | select -expand items

…it does limit the number of posts returned (albeit it returns 4 posts rather than 2 posts).

Am I doing something wrong?

The answer is this, really

Yep, use mp-destination to select a specific blog. For pagination, it also accepts limit and offset parameters. Doesn’t look like we documented this. So, if you want to page through 100 items at a time, the 2nd request can be like offset=100&limit=100 , 3rd request offset=300 , and so on. You can ask for more than 100 at a time, but I’d probably stick to 100-200 items to keep each request fast.

A couple of questions about the recent uploads API - #3 by sod

So offset would work to get older posts…not quite in the same way as ‘before’ or ‘before_id’ would, obviously, but it’s enough to get me going :slight_smile: