PUT/PATCH request with postman returns status code 0 in Laravel

I have written some REST API Methods, including one for updating a DB entry:

// Update
public function update(CreateAEDRequest $request, $id) {
    $aed = AED::find($id);

    if(!$aed) {
        return response()->json(['message' => "Dieser AED exisitiert nicht", 'code' => 404], 404);
    }

    $owner = $request->get('owner');
    $street = $request->get('street');

    $aed->owner = $owner;
    $street->street = $street;

    $aed->save();

    return response()->json(['message' => 'Der AED wurde aktualisiert'], 200);
}

The Route is defined as:

    Route::put('/aeds/{aeds}', 'APIAEDController@update');
    Route::patch('/aeds/{aeds}', 'APIAEDController@update');

A Request is being handled by:

namespace AppHttpRequests;

use AppHttpRequestsRequest;
use IlluminateHttpJsonResponse;

class CreateAEDRequest extends Request
{
    public function authorize()
    {
        // turn back to false when doing auth
        return true;
    }

    public function rules()
    {
        return [
            'owner' => 'required',
            'street' => 'required'
        ];
    }

}

But when I use postman and try to update the existing DB entry and I fill in the owner and street variable to be sent in POSTMAN as requested, I get the message: “Could not get any response. Returns Status Code 0”

enter image description here

All the other methods work fine. Is the definition of my routing not correct?

Update
When I send the data as x-www-form-urlencodedit works! When I send them as form-data it brings up the error message.


Source: laravel

Leave a Reply