Search code examples
laravellaravel-5eloquentpostman

Laravel API not accepting JSON request from Postman


Laravel API is not accepting JSON request. If I request as form-data it works but if I post JSON object in postman body then it does not receive the request data.

Route:

$router->group(['prefix' => 'imp'], function () use ($router) {
    $router->group(['prefix' => 'lead'], function () use ($router) {
        $router->post('/jardy', 'FeedController@jardy');
    });
});

Controller:

 public function jardy(Request $request)
    {

        $this->validate($request, [
            'api_key' => 'required',
        ]);
        $api_key = $request->input('api_key');
        return $api_key;
}

JSON Request:

Postman request using JSON

Form data Request:

Postman request using Form data

Why its not working in case of JSON, content-type is application/json, Accept:*/*???


Solution

  • Comments are not permitted in JSON. There's a bug in the field Body -> raw -> json