# Updating and saving topic on button press results in 404 not found

**URL:** https://meta.discourse.org/t/updating-and-saving-topic-on-button-press-results-in-404-not-found/56922
**Category:** Development
**Created:** [February 4, 2017, 11:51pm UTC](https://meta.discourse.org/t/updating-and-saving-topic-on-button-press-results-in-404-not-found/56922 "2017-02-04T23:51:41Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Janno\_Liivak](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/janno_liivak/32/352215_2.png) [@Janno\_Liivak](https://meta.discourse.org/u/Janno_Liivak)
#### Post date: [February 4, 2017, 11:51pm UTC](https://meta.discourse.org/t/updating-and-saving-topic-on-button-press-results-in-404-not-found/56922/1 "2017-02-04T23:51:41Z")

</div>

I have a plugin which places a button after main buttons. When pressing a button I would like to update topic and save it. But topic.save(props); results in 404 not found. Debugging reveals that Discourse is trying to PUT at /topics/:topic\_id instead of /t/:topic\_id. Is there something I’m doing wrong or is it a bug?

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [February 5, 2017, 6:12am UTC](https://meta.discourse.org/t/updating-and-saving-topic-on-button-press-results-in-404-not-found/56922/2 "2017-02-05T06:12:47Z")

</div>

Hmm do you know which part of the code base is trying to hit the /topics/:topic\_id route?

---

<div class="post-metadata">

### Author: ![Janno\_Liivak](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/janno_liivak/32/352215_2.png) [@Janno\_Liivak](https://meta.discourse.org/u/Janno_Liivak)
#### Post date: [February 5, 2017, 7:11am UTC](https://meta.discourse.org/t/updating-and-saving-topic-on-button-press-results-in-404-not-found/56922/3 "2017-02-05T07:11:35Z")

</div>

Yes. It’s a rest adapter’s pathFor(store, type, findArgs) {…}. It will be called through store model’s update() method (which is called from rest model’s update() method.

[https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/models/rest.js.es6#L8-L30](https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/models/rest.js.es6#L8-L30)

This is my plugin where I get this behaviour:

> <https://github.com/jannolii/discourse-bump-topic/blob/master/assets/javascripts/discourse/connectors/after-topic-footer-main-buttons/bump-topic.js.es6#L6>

---

<div class="post-metadata">

### Author: ![Janno\_Liivak](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/janno_liivak/32/352215_2.png) [@Janno\_Liivak](https://meta.discourse.org/u/Janno_Liivak)
#### Post date: [February 6, 2017, 10:07pm UTC](https://meta.discourse.org/t/updating-and-saving-topic-on-button-press-results-in-404-not-found/56922/4 "2017-02-06T22:07:41Z")

</div>

I have a feeling that I’m doing something wrong here (namely in mu plugin code which I pointed out above). Should I do rather somethink like:

```
Discourse.Topic.update(topic, props);

```

No? Yes?  
Kind of works … no error with this change … but nothing get’s saved also into the database ☹

Can somebody please point me a right direction? …Please

---

<div class="post-metadata">

### Author: ![Janno\_Liivak](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/janno_liivak/32/352215_2.png) [@Janno\_Liivak](https://meta.discourse.org/u/Janno_Liivak)
#### Post date: [February 9, 2017, 8:50pm UTC](https://meta.discourse.org/t/updating-and-saving-topic-on-button-press-results-in-404-not-found/56922/5 "2017-02-09T20:50:48Z")

</div>

I kind of feel like I’m having a conversation with myself 😉

Anyway … Found a missing logic in my plugin code, BUT … also had to change Discourse. Created PR [Create correct topic path for REST adapter by jannolii · Pull Request #4698 · discourse/discourse · GitHub](https://github.com/discourse/discourse/pull/4698)
