Kan de API voor het toevoegen en verwijderen van groepseigenaren niet bevatten

AI-generated summary

In a support discussion titled ā€˜Cannot fathom the API for adding and removing group owners,’ Nikki_Locke seeks clarification on undocumented API endpoints for managing group owners in Discourse 3.4.7. They report that while some endpoints work (e.g., PUT /groups/<gid>/owners and DELETE /admin/groups/<gid>/owners), others (like PUT /admin/groups/<gid>/owners) return 404 errors — despite matching source code from 2023. NateDhaliwal notes a possible typo in the original post. pfaffman suggests using the reverse engineering guide for API documentation and questions whether authentication is the issue, though Nikki_Locke confirms the same API key works for three of the four tested endpoints. pfaffman later shares their own successful example: PUT /groups/75/owners.json with usernames=pfaffman123 in form data, and reiterates the reverse engineering guide. tobiaseigen checks in to see if the issue was resolved. The core confusion remains around inconsistent endpoint behavior and lack of official documentation.

Ik wil groepeigenaren toevoegen en verwijderen via de API. Dit staat niet gedocumenteerd in de API-documentatie.

Door de aanroepen te traceren terwijl ik ben ingelogd als beheerder, is het toevoegen van een gebruiker als eigenaar:

PUT groups/<gid>/owners met een payload van usernames=nikkilocke (let op geen admin!)

Het verwijderen van een gebruiker uit de eigenaren is:

DELETE admin/groups/<gid>/owners met een payload van user_id=<uid>

Door de broncode te bestuderen blijkt:

      def group_add_owners(group_id, args)
        args = API.params(args).required(:usernames).to_h
        put("/admin/groups/#{group_id}/owners.json", group: args)
      end

      def group_remove_owners(group_id, args)
        args = API.params(args).required(:usernames).to_h
        delete("/admin/groups/#{group_id}/owners.json", group: args)
      end

en deze code lijkt sinds 2023 niet te zijn gewijzigd.

Ik gebruik Discourse 3.4.7 en het ingangspunt voor het toevoegen van eigenaren in de broncode geeft een 404-fout.

Pogingen met URL’s:

PUT /groups/384/owners usernames=nikkilocke OK

PUT /admin/groups/384/owners group[usernames]=nikkilocke 404-fout

DEL /admin/groups/384/owners group[usernames]=nikkilocke OK

DEL /admin/groups/384/owners user_id = 12 OK

Kan iemand mij adviseren wat er aan de hand is en welke URL’s ik hiervoor moet gebruiken?

I assume that that’s a typo and not the cause of your error?

The best and surest documentation for the API is Reverse engineer the Discourse API

Are you sure that you have a valid API key and that you are passing it correctly? A 404 error is expected if you are not properly authenticated.

Are you able to do any requests that require authorization?

Zoals ik al zei in het oorspronkelijke bericht, werken 3 van de 4 mogelijkheden prima (met dezelfde API-sleutel).

Ah. Sorry. The ā€œOKā€ at the end of the line was somehow too subtle for me to follow.

When I add an owner, I see this PUT request https://example.com/groups/75/owners.json with usernames= pfaffman123 in the form data.

Did you follow the reverse engineering steps I linked to?

@Nikki_Locke heb je je probleem kunnen oplossen?