إضافة أعضاء المجموعة مقابل إضافة مالكيها: تنسيق البيانات مختلف

عند استخدام واجهة برمجة التطبيقات (API) لإضافة أعضاء ومالكين إلى مجموعة، يبدو أن تنسيق البيانات المطلوب مختلف. قد يكون ذلك مقصودًا، لكنني أود معرفة السبب (فهذا يكسر مكتبة pydiscourse، وهي أفضل مكتبة أعثر عليها للتفاعل مع واجهة برمجة تطبيقات Discourse في بايثون).

إضافة عضو إلى مجموعة:

curl -X PUT "https://{mydomain}/admin/groups/{group_id}/members.json" \ 
    -d 'usernames={my-username}' \
    -H "Api-Key: {my-api-key}" \
    -H "Api-Username: {my-api-username}"

إضافة مالك إلى مجموعة:

curl -X PUT "https://{mydomain}/admin/groups/{group_id}/owners.json" \ 
    -d 'group[usernames]={my-username}' \
    -H "Api-Key: {my-api-key}" \
    -H "Api-Username: {my-api-username}"

أنا فضولي بشأن سبب ضرورة كتابة مفتاح معامل اسم المستخدم في نقطة نهاية المالكين على النحو group[usernames] بدلاً من مجرد usernames؟

The only reason I can give as to why is that they are actually using two different controllers.

The add members endpoint is mapped to the groups controller:

PUT /admin/groups/:id/members(.:format) groups#add_members 

And the add owners endpoint is mapped to the admin groups controller.

PUT /admin/groups/:id/owners(.:format) admin/groups#add_owners

It’s unlikely we will update this endpoint because lots of integrations already use this endpoint as is. You best bet is to open up an issue in the pydiscourse repo. You could also monkey patch a fix for add_group_owner in your python app until it gets resolved inside of pydiscourse.

إعجاب واحد (1)