What user type should I be using to add a member to a group via the API? If I go to /admin/users/list/active I appear to have three types of users: admin users, moderators, unprivileged.
I’ve created a few admin users and verified them against the api using a get request for site settings:
curl -X GET "https://my.discourse.com/admin/site_settings.json" -F "api_key=theGeneratedAPIKeyForanAdmin" -F "api_username=anAdmin"
This returns the site settings, However attempting to add a user to a group or even add a topic fail with the same api users.
For instance:
curl -X POST "https://my.discourse.com/posts" -H "Content-Type: multipart/form-data;" -F "api_key=theGeneratedAPIKeyForanAdmin" -F "api_username=anAdmin" -F "title=This is an API created topic" -F "topic_id=38" -F "raw=This is the end of the world as we know it, and I feel fine."
returns:
{"action":"create_post","errors":["Something has gone wrong. Perhaps this topic was closed or deleted while you were looking at it?"]}
I’ve left category, target_usernames, archetype, create_at out of the curl command as they’re optional (according to the api docs).
curl -X POST "https://my.discourse.com/posts" \
-H "Content-Type: multipart/form-data;" \
-F "api_key=theGeneratedAPIKeyForanAdmin" \
-F "api_username=anAdmin" \
-F "title=This is an API created topic" \
-F "raw=This is the end of the world as we know it, and I feel fine."
When creating a group be sure to use the id of the group and not the name of the group and to use a PUT request:
Than you for your patience, and Fantastic! I am new to discourse and managing forums, the wording for Discourse API Docs topic_id could be clearer. ‘Required when replying to topic or post.’ or similar.
In regard to group_id? How is this discoverable? In the GUI, I see the title, short_name (name) and nothing else. From the api docs, it looks like I need to GET from /admin/groups.json, but that returns no value.