الآن بعد وجود استدعاء API لدمج المستخدمين، كيف يمكن استدعاؤه؟

مرحباً،

لقد بدأت موضوعاً بالأمس (تم إغلاقه الآن) حول استدعاء إضافة “دمج المستخدمين” برمجياً، وأحسنت إليّ رافائيل بالإحالة إلى ملاحظات الإصدار، والتي تذكر أن الإضافة أصبحت الآن تحتوي على واجهة مستخدم (Discourse 2.5.0.beta3 Release Notes). للأسف، لا تملك مهاراتي في واجهة برمجة تطبيقات Discourse ما يكفي لترجمة ذلك إلى استدعاء API. هذا شيء سنحتاج إلى القيام به من تطبيقنا بشكل متكرر. هل يمكنك مساعدتي، من فضلك؟

شكراً مقدماً،

مارك بيمبرن
بلو أوشن إديز

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

The button is visible at the bottom of a user’s administration page.

If you open your browser developer tools while using it, you will see the request that needs to be made.

6 إعجابات

Hi Kane,

Thanks for the tip! It took me a while to be able to create some users in my sandbox Discourse, but I was able to do so today. I took what I gleaned from the dev tools Network panel and attempted to duplicate it via Postman. These are the values:

Method: POST
Endpoint: https://my-discourse-sandbox/admin/users/{source user ID}/merge.json

Headers:

Content-Type: multipart/form-data
Accept: application/json

Params:

Api-Key: {create via the UI}
Api-Username: system
context: /admin/users/{source user ID/{source username}
target_username: {target username}

The response was:

    {
        "errors": [
            "The requested URL or resource could not be found."
        ],
        "error_type": "not_found"
    }

Any idea of what I’m doing wrong?

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

Those all look correct at a glance. Have you checked that the target_username value exists?

إعجابَين (2)

Kane,

Yes, both source and target are current users. If I remove the headers, I get back an HTML page that says “Oops! That page doesn’t exist or is private.” The “page doesn’t exist” part is understandable for a 404 error, but I’m not sure what “private” implies here.

Mark

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

هل نجحت في ذلك؟

أقوم بترحيل بعض القوائم البريدية إلى مثيل discourse. نظرًا لأن العديد من الأشخاص استخدموا رسائل بريد إلكتروني مختلفة، فإن عملية النقل تنشئ العديد من المستخدمين المرحليين لكل شخص حقيقي. أود أتمتة دمج المستخدمين عبر واجهة برمجة التطبيقات.