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

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?

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

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.


This is my plugin where I get this behaviour:

1 Like

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

Can somebody please point me a right direction? …Please

1 Like

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

Anyway … Found a missing logic in my plugin code, BUT … also had to change Discourse. Created PR https://github.com/discourse/discourse/pull/4698