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

russellwwest's avatar

PUT request values are empty

I am using Lumen for my API. I have a PUT method for updating a product. However, the data is not available in the request object. Why is that? I've seen a few mentions of having to "fool" it by adding _method = put

Surely for an API framework, PUT should work out the box? or am i not understanding?

Thanks

$router->post('/products', 'ProductController@create');
$router->get('/products', 'ProductController@list');
$router->put('/products/{id}', 'ProductController@update');
$router->get('/products/{id}', 'ProductController@show');

controller:

public function update($id, Request $request)
    {
        $product = $this->productService->editProduct($id, $request);
        if (! $product) {
            return response()->json(['success' => false], 500);
        } else {
            return response()->json(['success' => true], 200);
        }
    }

service

public function editProduct($id, $request)
    {
        $product = Product::find($id);
        $product->name = $request->input('name');
        $product->description = $request->input('desc');
        if ($product->save()) {
            return true;
        } else {
            return false;
        }
    }
0 likes
3 replies
russellwwest's avatar
russellwwest
OP
Best Answer
Level 1

My bad! In postman I was sending the data as "form-data". Changing the option of the data type to "x-www-form-urlencoded" fixed the issue :)

10 likes

Please or to participate in this conversation.