إنشاء/إعادة إنشاء api_key لـ API مستخدم لا يعمل

أنا أحاول الحصول على مفتاح API لمستخدم، لكنني أحصل على استجابة 404.
تعمل واجهات برمجة التطبيقات (APIs) الأخرى الخاصة بي بشكل صحيح، لذا لا توجد مشكلة في الرؤوس (headers). كما قمت بفحص إعدادات الواجهة الخلفية (backend) ولا توجد مشكلة فيها.

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

The endpoint to create a new API key has changed - we’re working on updating the documentation ASAP. You can now create a new API key like this:

curl -X POST http://localhost:3000/admin/api/keys \
  -H "Content-Type: multipart/form-data;" \
  -H "Api-Key: $api_key" \
  -H "Api-Username: system" \
  -F "key[description]=testing" \
  -F "key[username]=bobby"

I would be interested to know why you are creating new API keys… using an API key. It seems a little circular, and I wonder if we can come up with a better solution for your problem?

7 إعجابات

I have created a new user via API. (with admin API and KEY)
now I need to post a post or topic for this user.

But seems no API for me to do that… So I think maybe I should create a API for this user, then I switch my header with this new API… then I can make a post or topic on behalf of this new user…

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

Rather than creating a key for each user, you can use an “all users” key, then change the Api-Username header on the request. There is an example at the top of https://docs.discourse.org/

3 إعجابات

great man! thanks. that works perfectly !

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

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.