I'm building an API to support an external application. I have added several routes to it with no problem, but suddenly, when I add a new route (acars/delay
), I get a 404 error when trying to hit http://myurl.dev/api/acars/delay
with a POST request. Here is my api.php
file:
Route::post('acars/deactivate', 'API\AcarsController@deactivate');
Route::post('acars/ofp', 'API\AcarsController@ofp');
Route::post('acars/create', 'API\AcarsController@create');
Route::post('acars/pirep', 'API\AcarsController@pirep');
Route::post('acars/mx', 'API\AcarsController@mx');
Route::post('acars/delay', 'API\AcarsController@delay'); // <-- THIS IS THE BROKEN ROUTE
Controller method:
public function delay(Request $request) {
$acars = AcarsFlight::findOrFail($request->acars_flight_id);
$delay = AcarsDelay::create([
...
]);
return $delay;
}
The other routes work fine, but acars/delay
returns a 404 in Postman every time. My php artisan route:list
output looks like this:
There are no wildcards causing conflicts. I have tried clearing my route cache multiple times, restarting the server, etc. I have also tried moving the broken route to different positions in the api.php
file, but no luck. The only thing I can think of is that I recently upgraded the application from Laravel 6 to 8. I read the upgrade guides for v7 and v8, and the only thing I found was that in starting v7, unique route names are required, a requirement I believe I have met. I have verified about a thousand times that I'm using the right URL. Copying+pasting the URL into the browser gives me the extected 405
error.
It might be because of something like findOrFail
method in your controller. Try to dd
at start of your controller and try requesting with Postman again.