# Not able to add Whisper Post Using API

**URL:** https://meta.discourse.org/t/not-able-to-add-whisper-post-using-api/161145
**Category:** Development
**Tags:** rest-api, whispers
**Created:** [August 17, 2020, 2:00pm UTC](https://meta.discourse.org/t/not-able-to-add-whisper-post-using-api/161145 "2020-08-17T14:00:48Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Minhaj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/minhaj/32/137595_2.png) [@Minhaj](https://meta.discourse.org/u/Minhaj)
#### Post date: [August 17, 2020, 2:00pm UTC](https://meta.discourse.org/t/not-able-to-add-whisper-post-using-api/161145/1 "2020-08-17T14:00:48Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [August 17, 2020, 11:01pm UTC](https://meta.discourse.org/t/not-able-to-add-whisper-post-using-api/161145/2 "2020-08-17T23:01:09Z")

</div>

`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:

```plaintext
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

```

 ![image](https://global.discourse-cdn.com/meta/original/3X/4/7/478ca3973c8ed0d71ecfae2a460ebb03c8830b7a.png)

---

<div class="post-metadata">

### Author: ![Minhaj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/minhaj/32/137595_2.png) [@Minhaj](https://meta.discourse.org/u/Minhaj)
#### Post date: [August 18, 2020, 6:05am UTC](https://meta.discourse.org/t/not-able-to-add-whisper-post-using-api/161145/3 "2020-08-18T06:05:51Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [August 18, 2020, 3:41pm UTC](https://meta.discourse.org/t/not-able-to-add-whisper-post-using-api/161145/4 "2020-08-18T15:41:54Z")

</div>

> [@Minhaj](#):
>
> 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.

> <https://github.com/discourse/discourse/blob/main/app/models/post.rb#L145-L150>

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

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [September 17, 2020, 3:48pm UTC](https://meta.discourse.org/t/not-able-to-add-whisper-post-using-api/161145/5 "2020-09-17T15:48:36Z")

</div>

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