Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

onurzdgn's avatar

Post with API

Hi I am using Laravel 8.

Route::post('baseStation', [BaseStationController::class, 'send']);

I have this route on "api.php" but when I try to go "localhost/send/basestation" the page not found, it gives me 404. On the other hand, I heve

Route::get('baseStation', [BaseStationController::class, 'api']);

and this is workin. It gives me json. How can I fix this?

0 likes
3 replies
LaryAI's avatar
Level 58

It looks like you are trying to make a POST request to the baseStation route, but you have only defined a GET route. To fix this, you will need to add a POST route to your api.php file.

Route::post('baseStation', [BaseStationController::class, 'send']);

Once you have added the POST route, you should be able to make a POST request to the baseStation route.

webrobert's avatar
Level 51

Aren’t your api routes prefixed with api?

Please or to participate in this conversation.