Search code examples
jsonblogger

Cannot retrieve previous page token for Blogger v3 API


I'm trying to make a simple API request using Google's Blogger API. Specifically, I'd like to get a list of posts for my blog and display 3 results at a time, allowing for paging forwards AND backwards. I'm having troubles getting a "previousPageToken" response back from the API and think I might be doing something wrong as their example they have does include this property when appropriate. This is the example I'm following and their proposed output. enter image description here

Below is the same url with the same blog id. The blog has hundreds of posts.

The request (I removed my API key):

https://www.googleapis.com/blogger/v3/blogs/2399953/posts?key=API-KEY&maxResults=3

The response:

 "kind": "blogger#postList",
 "nextPageToken": "CgkIAxiA7Pz3iCsQ0b2SAQ",
 "items": [...

Okay fine that's page 1 so I don't expect a previous page token.

Next page request: https://www.googleapis.com/blogger/v3/blogs/2399953/posts?key=API-KEY&maxResults=3&pageToken=CgkIAxiA7Pz3iCsQ0b2SAQ

 "kind": "blogger#postList",
 "nextPageToken": "CgkIAxiAoM68xyoQ0b2SAQ"
 "items": [...

Uh, what? We are on page two but the API didn't return a previous page token.

Am I querying incorrectly or misunderstanding something?


Solution

  • Thanks to Jon Skeet on the .NET client library on GitHub he identified this as a documentation bug. The "PreviousPageToken" property no longer exists in v3 of the Blogger API - but did exist in V2. I was able to work around the now-missing property by storing the publish dates of the starting and ending posts from my result set and using those to go forward and backward using the startDate and endDate API parameters.