# 500 or 400 when updating the content of a post using the API

**URL:** https://meta.discourse.org/t/500-or-400-when-updating-the-content-of-a-post-using-the-api/115825
**Category:** Development
**Tags:** rest-api
**Created:** [24.Апрель.2019 09:30:24 UTC](https://meta.discourse.org/t/500-or-400-when-updating-the-content-of-a-post-using-the-api/115825 "2019-04-24T09:30:24Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![jviotti](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jviotti/32/138866_2.png) [@jviotti](https://meta.discourse.org/u/jviotti)
#### Post date: [24.Апрель.2019 09:30:24 UTC](https://meta.discourse.org/t/500-or-400-when-updating-the-content-of-a-post-using-the-api/115825/1 "2019-04-24T09:30:24Z")

</div>

I’m trying to update the content of a post using the API. The docs at [Discourse API Docs](https://docs.discourse.org/#tag/Posts%2Fpaths%2F~1posts~1%7Bid%7D.json%2Fput) mention that I should use `PUT /posts/:id.json` sending `post[raw]` as a body.

This results in 400 along with:

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

```

The error is complaining about a param called `post`, but replacing `post[raw]` with `post` in my HTTP request results in a 500 Internal Server Error response.

The post content was just `Edited comment`, so I don’t think it’s anything related to the content.

Am I missing something? Are the API docs out of date?

I’m running a cloud instance at [https://forums.balena.io](https://forums.balena.io). Not sure what the Discourse version is.

---

<div class="post-metadata">

### Author: ![jviotti](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jviotti/32/138866_2.png) [@jviotti](https://meta.discourse.org/u/jviotti)
#### Post date: [24.Апрель.2019 09:50:27 UTC](https://meta.discourse.org/t/500-or-400-when-updating-the-content-of-a-post-using-the-api/115825/2 "2019-04-24T09:50:27Z")

</div>

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:

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

```

With body:

```plaintext
{
    "post": "Edited comment"
}

```

And that still results in 500.

---

<div class="post-metadata">

### Author: ![jviotti](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jviotti/32/138866_2.png) [@jviotti](https://meta.discourse.org/u/jviotti)
#### Post date: [24.Апрель.2019 09:52:30 UTC](https://meta.discourse.org/t/500-or-400-when-updating-the-content-of-a-post-using-the-api/115825/3 "2019-04-24T09:52:30Z")

</div>

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

---

<div class="post-metadata">

### Author: ![jviotti](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jviotti/32/138866_2.png) [@jviotti](https://meta.discourse.org/u/jviotti)
#### Post date: [24.Апрель.2019 09:56:24 UTC](https://meta.discourse.org/t/500-or-400-when-updating-the-content-of-a-post-using-the-api/115825/4 "2019-04-24T09:56:24Z")

</div>

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

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [24.Апрель.2019 12:14:51 UTC](https://meta.discourse.org/t/500-or-400-when-updating-the-content-of-a-post-using-the-api/115825/5 "2019-04-24T12:14:51Z")

</div>

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: [Reverse engineer the Discourse API](https://meta.discourse.org/t/how-to-reverse-engineer-the-discourse-api/20576) 😉

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

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [01.Август.2022 04:37:48 UTC](https://meta.discourse.org/t/500-or-400-when-updating-the-content-of-a-post-using-the-api/115825/7 "2022-08-01T04:37:48Z")

</div>


