I am creating an API but stuck debugging.
Using this in my controller method:
$this->validate($request, [
'project_id' => 'required',
'content' => 'required',
]);
If I call that route with PostMan I get a not found error return by Laravel's debugging screen.
However the API call works fine when using an Angular (ionic) $http request.
Any help?
Checkout the code from FormRequest
When you use angular, Laravel knows you are sending ajax requests. When using Postman, Laravel thought it's a form request and redirect you to previous page which is 404. The solution is to add a header
Accept: application/json
in postman requests, so that Laravel knows youwantsJson()
orX-Requested-With: XMLHttpRequest
so Laravel thinks it's aajax()
request.You can try the following