Should watching/unwatching a forum use get or post http method in rails

54 views Asked by At

I understand, in general, the differences between GET and POST, and common use cases. This question is specific to actions that would toggle the state of something. For example, if users have the ability to "watch" (or "unwatch") a forum to be notified of changes, my inclination is to use a GET request to accomplish this, but is this something that is recommended to be a POST or a GET? Can using GET cause any issues in this case?

1

There are 1 answers

0
rmagnum2002 On

It won't create any issues, but it's recommended to use methods POST/PUT for create/update, GET for getting info and DELETE for deleting a record.

In your case I am thinking you have a relation between user and forum that handles the watching, unwatching a forum.. cause user can probably watch/unwatch multiple forums, in this case when he unwatches it you basically delete this relation between user and forum, so you'll need to do it via a DELETE method.

If you don't have a relation between users and forums, instead you keep the forum id in users table, unwatching would mean to update that user record, in this case you'd want to use PUT method.

http://www.restapitutorial.com/lessons/httpmethods.html