cesartc

I can not get inputs from a PUT/PATCH request

I am developing a rest api. I test it with Postman Rest Client. But I have had a headache with PUT and PATCH requests, the sent parameters can not be gotten in the controller with Input::get('param') neither Request::get('param') they always return NULL, I don't understand why. In the store method it works well.
PD: I'm not using resourceful controllers (because I thought it could be the problem), I declared it with Route::put()

This is my controller, the store method works well: http://laravel.io/bin/bPb

And here is how I use postman: http://s13.postimg.org/4o0raxufr/postman.jpg

Delete Reply

well, finally I'm not sure about what happens, the put/patch requests go to the right controller method but the inputs couldn't be gotten. I had to use post requests instead of put/patch, breaking the REST best practices :c

Delete Reply

Wow, thanks guys for figuring this out!
I just spent about an hour trying to find out why my API wont work on PUT/PATCH.
My issue was exactly the same with POST working fine but updates had an empty request body when testing via Postman.

I'm glad I finally found this thread and an answer after severely doubting my understanding of Laravel 5's routing and the new FormRequest validation.

Delete Reply

Anyone worked out how to get this working with PUT/PATCH and form-data? I need to submit files along with the request. For now I've fallen back to using a POST with the _method = PUT but would ideally like a nicer way of dealing with this.

Delete Reply

Anyone worked out how to get this working with PUT/PATCH and form-data? I need to submit files along with the request. For now I've fallen back to using a POST with the _method = PUT but would ideally like a nicer way of dealing with this.

You are my 2nd saviour :d I don't know we could cheat POSTMAN by using that trick
This is my case :

I want to use method PUT to upload file with POSTMAN. But if I point data to x-www-url-formurlencoded, it would not allow me to use File input. So in this case, with POSTMAN, I use POST, but with a _method input equal to PUT. It will allows me to PUT data with file (This trick only works with Laravel)