Reputation: 11
I am using laravel 5 for creating restful api, is it right way to use post method instead of put method for updating a record, as I see no difference in using the both, as the complete logic for updating a value is written inside my controller, it will be helpful if someone suggest which is right method to go a head.
Upvotes: 1
Views: 255
Reputation: 474
You should use PUT/PATCH
. That's a non-arguable. It is a standard in implementing RESTful APIs just like PSR standards.
There's a reason why there are different HTTP verbs.
An excerpt from an article:
The HTTP verbs comprise a major portion of our “uniform interface” constraint and provide us the action counterpart to the noun-based resource.
See article here.
Upvotes: 1
Reputation: 2924
You can use POST
, but I wouldn't recommend it. If you want to update data, there should be used PUT
.
What if later you want to change something in create method with POST
, which you doesn't really want in update?
I recommend to read a bit, f.ex. I found last time really helpful article:
Upvotes: 0