alldritt
(Mark Alldritt)
October 12, 2018, 5:13pm
1
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
simon
October 12, 2018, 5:34pm
2
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
alldritt
(Mark Alldritt)
October 12, 2018, 5:46pm
3
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.
blake
(Blake Erickson)
October 12, 2018, 7:37pm
4
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?
blake
(Blake Erickson)
October 12, 2018, 8:20pm
5
Ohh I see you are trying to do this from iOS Shortcuts:
This post describes how to post new topics to a Discourse forum using the new iOS Shortcuts app.
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
alldritt
(Mark Alldritt)
October 12, 2018, 9:18pm
6
Thanks, good spotting. I have some AppleScript code that generates the GET URL correctly and that returns all the categories.
4 Likes
system
(system)
Closed
November 11, 2018, 9:22pm
7
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.