I have a fresh 5.3 installation and want to make api calls with postman. I also tried it with angular2 to make sure it's not a problem with postman.
In my routes/api.php
I got a simple route:
Route::post('test', function(\App\Http\Requests\LoginRequest $request) {
return $request->all();
});
LoginRequest is checking if the fields email and password are there. If so, the output is as excepted. But when it's missing it redirects to /
.
Do I have to add some information for form validation for ajax calls? I thought laravel would return a json error object when there is an ajax call.
Update:
I found out that I missed the Accept application/json
header in Postman. With it it works finde. But is there a way to say that all api/*
calls should be treated as a json call?