غير قادر على إضافة منشور Whisper باستخدام API

أنا غير قادر على إضافة منشور سري (Whisper) باستخدام واجهة برمجة التطبيقات (API). أقوم بتمرير حقل Whisper إلى true في هيكل Go المعطى.

type Post struct {
	TopicID   int       `json:"topic_id"`
	Raw       string    `json:"raw"`
	CreatedAt time.Time `json:"created_at"`
	PostType  int       `json:"post_type"`
	Whisper   bool      `json:"whisper"`
}

لا يبدو أن تعيين whisper إلى true أو post_type إلى 4 يعمل بالنسبة لي. يتم إضافة المنشور لكنه ليس منشورًا سريًا. ومع ذلك، أستطيع إضافة منشور سري عبر واجهة المستخدم، مما يوضح أن هذه ليست مشكلة صلاحيات. هل يمكن لأحد مساعدتي في معرفة ما أفعله خطأ؟

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

post_type shouldn’t be needed. If it has a topic_id it knows it is a post and not a new topic. This is how I’m doing it with curl:

curl -i -sS -X POST "http://localhost:3000/posts.json"  \
-H "Content-Type: multipart/form-data;"  \
-H "Api-Key: 079fb2bb12d3b436bb11bde8eb58aaa9a36560fa7d79b14b3087aa40b1ebc2c4"  \
-H "Api-Username: blake.erickson"  \
-F "raw=92d2e4a938f8d2c65e3fbbcf68e4c272 374f11b3488a03d5d299e862003b09a3 76cdef8f63901f150f2bbf5579cd0b22"  \
-F "topic_id=11"  \
-F "whisper=true"

HTTP/1.1 200 OK

5 إعجابات

This seems to be working, but why whisper=true is not returned in response. Instead I see post_type=4 in all the whispers as opposed to post_type=1, does that mean something or not.

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

Yes, that is a good thing. post_type=4 is a whisper post, which means it was created successfully. If it comes back at post_type=1 then it isn’t a whisper, but just a regular post.

The interface for creating posts just doesn’t allow you to pass in a post_type, but instead requires you to specify whisper=true.

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

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