Impossibile aggiungere Whisper Post tramite API

Non riesco ad aggiungere un post “whisper” tramite l’API. Sto passando il campo Whisper impostato su true nella struct Go fornita.

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"`
}

Né impostare whisper su true né impostare post_type su 4 sembra funzionare per me. Il post viene aggiunto, ma non è un whisper. Tuttavia, riesco ad aggiungere un whisper tramite l’interfaccia utente, il che chiarisce che non si tratta di un problema di privilegi. Qualcuno può aiutarmi a capire cosa sto sbagliando?

1 Mi Piace

post_type non dovrebbe essere necessario. Se ha un topic_id, sa che si tratta di un post e non di un nuovo argomento. È così che lo sto facendo con 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 Mi Piace

Sembra che funzioni, ma perché whisper=true non viene restituito nella risposta? Invece vedo post_type=4 in tutti i messaggi privati, anziché post_type=1. Questo significa qualcosa o no?

1 Mi Piace

Sì, è una cosa positiva. post_type=4 indica un messaggio privato, il che significa che è stato creato con successo. Se viene restituito come post_type=1, allora non è un messaggio privato, ma semplicemente un post normale.

L’interfaccia per la creazione dei post non consente di passare direttamente un post_type, ma richiede invece di specificare whisper=true.

1 Mi Piace

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