1

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.

Rekha S
  • 11
  • 1
  • You should follow global standards for API. Read this to answer your question https://stackoverflow.com/q/630453/5350773 – Zedex7 Jul 26 '17 at 06:30

2 Answers2

1

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.

elegisandi
  • 454
  • 3
  • 10
0

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:

REST flowcharts

Karol Gasienica
  • 2,825
  • 24
  • 36