لا وصف لفئة عبر API

مرحباً،

ما زلت أقوم باستيراد البيانات من تطبيق قديم إلى Discourse الجديد الخاص بنا.
لا يمكنني إنشاء فئة مع وصفها باستخدام استدعاء API التالي:

curl -X POST "https://site-discourse/categories.json" \
-H "Api-Key: api-key" \
-H "Api-Username: api-username" \
-d "name=categorie test" \
-d "description=Description De La Categorie"

تم إنشاء الفئة ولكن لا يوجد وصف.

أتلقى الاستجابة التالية:

{"category":{"id":21,"name":"categorie test",[...],"slug":"categorie-test", [...] **,"description":null**,"description_text":null,"description_excerpt":null,"topic_url":"/t/a-propos-de-la-categorie-categorie-test/12286", [...]}

شكراً لمساعدتكم.

مرحباً :blob_wave:

وصف الفئة هو محتوى موضوع “حول” الذي يتم إنشاؤه تلقائيًا. ومن المرجح أن يُعتبر النص الافتراضي “فارغًا” حتى يتم تعديله.

أعتقد أنه لا يوجد معرّف “وصف” متاح في الطلب الخاص بإنشاء فئة، وستحتاج إلى إرسال طلب API آخر لتحديث المشاركة الأولى في موضوع “حول”.

اعتمادًا على عملية الاستيراد لديك، قد ترغب في استخدام سكريبت استيراد مخصص بدلاً من استخدام واجهة برمجة التطبيقات. انظر Support > Migration

شكرا على ردك

لقد أنشأت هذا البرنامج النصي الذي يسمح لك بإنشاء فئة ثم تعديل وصفها:

curl -X POST "https://site-discourse/categories.json" \
 -H "Api-Key: api-key" \
 -H "Api-Username: api-username" \
 -d "name=Catégorie 1"

sleep 2

latest_posts_response=$(curl -X GET "https://site-discourse/posts.json" \
 -H "Content-Type: application/json" \
 -H "Api-Key: api-key" \
 -H "Api-Username: api-username")

post_id=$(echo $latest_posts_response | jq  '.latest_posts[0] .id')

curl -X PUT "https://site-discourse/posts/$post_id.json" \
 -H "Content-Type: application/json" \
 -H "Api-Key: api-key" \
 -H "Api-Username: api-username" \
 -d '{
        "post": {
        "raw": "Description de la catégorie 1"
      }
     }'

هل نجح الأمر في النهاية؟

نعم شكراً لك، لقد نجح الأمر!