Laravel 4.2 - 405 Method Not Allowed

Asked

Viewed 207 times

2

I have a route that was working normally and stopped working for no apparent reason. It has the following configuration:

Route::put('/clientes', 'Clientes@update');

The mistake I get is:

Method Not Allowed
The requested method PUT is not allowed for the URL /clientes/.

If I simply change the url to:

/anything

It works normally, someone can explain this problem, because it doesn’t make any sense to me. When I run the command "php Artisan Routes" the route is there, but I always get this error. Someone can give me a light?

Note: I already have several routes working in these patterns.

  • Why do you wear Route::put() ? The put specifically.

1 answer

2

To access the method PUT, it would be necessary that the request made to that url was also of the type PUT. This request cannot be made via form, only via ajax. Forms

The method not allowed is being returned because it is not an accepted method; that is, you are making a request of another type, when the expected one is of the type PUT.

There is a problem that my fellow programmer has already warned me is that if you access also the url with a / in the end, the requisition is recognized as GET. Try removing the end bar of the requested url.

Requests made by a browser are usually of the type GET.

This was not specified in the question: Whether the request was made by the browser or not.

  • Is it true about the GET. One day I was having problems accessing a page via Ajax. I was understanding how POST. So I thought, I’ll put postPagina() no Controller, then. Whatever. It still didn’t work. It was taking another way. Like localhost/url. Then it hit me that it was / at the end of the URL in the parameter url from Ajax. One More.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.