500 أو 400 عند تحديث محتوى منشور باستخدام واجهة برمجة التطبيقات

أحاول تحديث محتوى منشور باستخدام واجهة برمجة التطبيقات (API). تشير الوثائق في Discourse API Docs إلى أنه يجب استخدام PUT /posts/:id.json مع إرسال post[raw] كجسم الطلب.

يؤدي هذا إلى استجابة برمز 400 مع الرسالة التالية:

errors: [ 'param is missing or the value is empty: post' ]

يشكو الخطأ من وجود معلمة تسمى post، ولكن استبدال post[raw] بـ post في طلب HTTP الخاص بي يؤدي إلى استجابة برمز 500 (خطأ داخلي في الخادم).

كان محتوى المنشور ببساطة عبارة عن “تعليق معدل”، لذا لا أعتقد أن المشكلة تتعلق بالمحتوى نفسه.

هل أغفلت شيئًا ما؟ هل وثائق واجهة برمجة التطبيقات قديمة؟

أعمل على نسخة سحابية في https://forums.balena.io. ولا أعرف إصدار Discourse المستخدم.

I just realised I was passing a topic id instead of a post id to the API, but the problem still persists. I’m trying to update post 34816, assuming you have access to the cloud instance:

PUT https://forums.balena.io/posts/34816.json

With body:

{
    "post": "Edited comment"
}

And that still results in 500.

Why is my post being flagged as spam? Is this not the right place to submit bugs?

Turns out it works fine if I pass raw instead of post in the request body. The docs could probably be clearer about that :slight_smile:

4 إعجابات

Glad you got it figured out! I’ve got a bunch of topics that are me taking to myself.

Mostly these are the docs, and they are continually updated: How to reverse engineer the Discourse API :wink:

I generally forget that there are any docs besides just seeing how it works in the browser development tools.

5 إعجابات