Problem Description:Minhaj is unable to create a whisper post using the API, despite passing Whisper field as true in the post struct. However, creating a whisper post through the UI is successful.
Solution:blake suggests that post_type is not needed and provides an example using curl with whisper=true to create a whisper post successfully.
Follow-up:Minhaj confirms that the solution works but notices that the response does not return whisper=true. Instead, it returns post_type=4, which blake explains is a good sign, indicating that the post was created as a whisper post. According to the Discourse codebase, specifying whisper=true is required to create a whisper post, rather than setting post_type directly.
I am unable to add whisper post Using the API. I am passing Whisper field to true in the given go struct.
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"`
}
Both, setting whisper to true or post_type to 4 doesn’t seem to work for me. Post is being added but it is not a whisper. However I am able to add whisper through the UI which clarifies that this is not a privilege issue. Can somebody help me here what I am doing wrong?
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.
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.