mercredi 2 septembre 2020

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:*/*???



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2EGzMkF
via IFTTT

Aucun commentaire:

Enregistrer un commentaire