Categories.json API not returning Lounge and Staff categories

I’m trying to use the categories.json API end point to obtain the categories in my forum. I returns all the top level categories except for Lounge and Staff. My account has access to these categories.

I’m GETing https://discourse.example.com/categories.json?api_key=myAPIKEY&api_username=myusername

Is this just how it works, or do I need to specify additional information to get all the categories my Discourse account has access to?

I’m running: v2.2.0.beta2 +115

You should be able to get the Staff and Lounge categories from /categories.json. Make sure the user whose API key you are using has permission to view the Staff and Lounge categories.

2 Likes

Thanks for the response. I’m using my username for the API calls and I’m the site admin. I have access to these categories when I use my site interactively.

Without using the api can you just browse to this page as a logged in user

https://discourse.example.com/categories

and see Staff and Lounge? I assume so since

Do they still show up if you visit the .json version from a web browser?

https://discourse.example.com/categories.json

So far I’m unable to replicate your behaviour.

If you do:

curl -I https://discourse.example.com/c/staff.json

do you get a 404 response?

Try the same call with your api key/username

curl -I https://discourse.example.com/c/staff.json?api_key=myAPIKEY&api_username=myusername

Do you get still get a 404?

Ohh I see you are trying to do this from iOS Shortcuts:

I think the problem might be that you have put the api_key and api_username in the Headers field.

We don’t read normal api_keys and api_username out of the headers field, so I think your request is showing up as a non-authenticated user.

Are you able to put the api_key and api_username in the URL field?

3 Likes

Thanks, good spotting. I have some AppleScript code that generates the GET URL correctly and that returns all the categories.

4 Likes

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