Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

EckyEckyPtang's avatar

PATCH requests with 'form-data' parameters are not recognized

Working on a restful API and I'm stuck on this weird issue when trying to update a user.

The resource controller is defined as follows:

Route::resource('users', 'Api\UsersController');

The patch URI looks like:

/api/users/{id}

The corresponding method looks as follows:

public function update(Request $request, $id)
{
    dd($request->all()); //Always empty array, why?
    ...
}

So then tried in POSTman to send the same patch request. In POSTman you can send parameters in the body as type form-data or x-www-form-urlencoded. When using form-data, request->all() is always empty. The params send via x-www-form-urlencoded are sent correctly.

There is also a way to pass params with the button next to the URL in POSTman. This works as well. I do need to send them as form-data, because the patch request has to send a file along.

Does anyone know why the Laravel Request object is empty? And also what the difference is between those 3 types of parameters in POSTman?

Frank

0 likes
11 replies
fireproofsocks's avatar

So curious about this... having the same trouble using curl to send PATCH requests -- form data doesn't make it through.

usama.ashraf's avatar

@kylescousin when using something like Postman, send a POST request and add a "_method" field with the value "PATCH".

The same goes for "PUT" by the way.

4 likes
phpMick's avatar

I know this is an old post but I am currently experiencing this.

m_mamdouh's avatar

Hi @kossa did you i know also its long time but did you found a solution for that ?

OnionKnight99's avatar

I know this is an old post but here is a solution to getting the API to see the $request fields without having to spoof the PUT method.

1: Create the following middleware file in your “app/Http/Middleware” folder:

  1. Add this middleware in “App\Http\Kernel” file in the middleware api group.

  2. Save and you are done.

All API update (PUT/Patch) will be fixed for form/data requests

M.Yanis's avatar

We have two possibilities either add hidden field of PUT or PATCH or just add the method Blade directive : @method ('PUT') or PATCH

<form action="/foo/bar" method="POST">
    <input type="hidden" name="_method" value="PUT">
    <input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>

Or

<form action="/foo/bar" method="POST">
    @method('PUT')
    @csrf
</form>

Please or to participate in this conversation.