# Updating deleted post through API returns Internal Server Error

**URL:** <https://meta.discourse.org/t/updating-deleted-post-through-api-returns-internal-server-error/75839>\
**Category:** Bug\
**Created:** [December 11, 2017, 8:48pm UTC](https://meta.discourse.org/t/updating-deleted-post-through-api-returns-internal-server-error/75839 "2017-12-11T20:48:02Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)\
**Post date:** [December 11, 2017, 8:48pm UTC](https://meta.discourse.org/t/updating-deleted-post-through-api-returns-internal-server-error/75839/1 "2017-12-11T20:48:02Z")

</div>

Attempting to update a deleted post through the API returns a `500` error. The error is `undefined method 'id' for nil:NilClass`. It’s coming from `web_hook.rb`.

The problem is that when publishing with the All Users API key the post `update` method is calling  
`post = post.with_deleted if guardian.is_staff?`. The deleted post is then being used to trigger a `DiscourseEvent`.

My reason for wanting to get a better response when a deleted post is updated is so that the [WP Discourse](https://github.com/discourse/wp-discourse) plugin can use the response to remove the Discourse metadata it has saved for a post. It’s not safe for the plugin to assume that a `500` response means that the post has been deleted.

---

_[View the full topic](https://meta.discourse.org/t/updating-deleted-post-through-api-returns-internal-server-error/75839)._
