לא מצליח להבין את ה-API להוספה והסרה של בעלי קבוצה

סיכום מבוסס בינה מלאכותית

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.

ברצוני להוסיף ולהסיר בעלי קבוצות באמצעות ה-API. הדבר אינו מתועד בתיעוד ה-API.

מעקב אחר הקריאות בעת כניסה כמנהל מערכת, הוספת משתמש כבעלים היא:

PUT groups/<gid>/owners עם מטען של usernames=nikkilocke (שימו לב, ללא admin!)

הסרת משתמש מבעלים היא:

DELETE admin/groups/<gid>/owners עם מטען של user_id=<uid>

לימוד קוד המקור מראה:


      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

והקוד הזה לא נראה שהשתנה מאז 2023.

אני מריץ Discourse 3.4.7, ונקודת הכניסה להוספת בעלים בקוד המקור מחזירה שגיאת 404.

כתובות URL שניסיתי:

PUT /groups/384/owners usernames=nikkilocke OK

PUT /admin/groups/384/owners group[usernames]=nikkilocke שגיאת 404

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

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

האם מישהו יכול לייעץ לי מה קורה, ואילו כתובות URL להשתמש עבור זה, בבקשה?

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?

כפי שאמרתי בפוסט המקורי, 3 מתוך 4 האפשרויות עובדות בסדר (עם אותו מפתח API).

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 האם הצלחת לפתור את הבעיה שלך?