/directory_items.json API returns wrong link for next page

I am trying to get post counts from the discourse API via the /directory_items.json endpoint.

The API returns a URL for retrieving the next page of items, however the URL I see is /directory_items?order=post_count&page=1&period=all while I expected the URL to include the .json extension: /directory_items.json?order=post_count&page=1&period=all.

As far as I see this is a bug, the API should return the URL for the next page for the format which I am currently using in the API request (json) and not the URL for the HTML page.

I am currently using discourse v2.1.0.beta5.

Not a bug. If you reverse engineer our Discourse API then you can find that we use extensionless endpoints in many places. If you add the Accept: application/json header in your requests then we will treat both /directory_items and /directory_items.json endpoints in same manner.

7 Likes

Aha that makes sense, thanks. This clearly needs to be documented, will see if I can improve the docs about it.

3 Likes
5 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.