API documentation error?

At this page the documentation states that detailed record for user can be obtained by GET /admin/users/{id}.json

Tests suggest this is not correct (returns 404) and the correct URL is GET /admin/users/{id}/{username}.json

Should I do a PR on the docs repo? Or do the team consider that the API expresses what the API should do, so this is actually an API bug?

Julian

I think you should revisit your tests. The first path works fine as long as it is a valid member id number

In fact, AFAIK, it is the only path that works with the account number and not the member name.

1 Like

Sorry @Mittineague I’m absolutely positive. Maybe this is a version change? I am running against Discourse 2.1.1

You can also see it -in the UI - when you look at details of a user they appear at
<mysite.com>//admin/users/{userid}/{username} while <mysite.com>//admin/users/{userid}/ is a 404

You have a few variations there. These work for me.
Discourse 2.2.0.beta2
.../admin/users/{userid}.json
.../admin/users/{userid}/{username}
.../admin/users/{userid}/{username}.json

1 Like

That one works for me too. I’ve been ignoring the .json suffix and just using the header as documented

Instead of sending API requests to /categories.json you may also send them to /categories and add an Accept: application/json header to the request to get the JSON response. Sending requests with the Accept header is necessary if you want to use URLs for related endpoints returned by the API, such as pagination URLs. These URLs are returned without the .json prefix so you need to add the header in order to get the correct response format.

but maybe I need to change my code to use it.

Routing is different for different paths. Do you have the Ember addon installed in your browser?

1 Like

I have now - so this is about reverse engineering the API?

2 Likes