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

dsimon24cx's avatar

Laravel API not accessible via POST request - Error 404.

Hello all.

I am currently trying to implement an API in Laravel. But unfortunately without success. Rather with an error message 404 - not found.

I created an API controller in app/Http/Controllers/Api/SocialMediaController.php with the corresponding route in Api.php "Route::apiResource('/socm', 'App\Http\Controllers\Api\SocialMediaController');".

The controller looks like this:

namespace App\Http\Controllers\Api;

use Illuminate\Support\Facades\Storage;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class SocialMediaController extends Controller
{
    /**
     * Store a newly created resource in storage.
     */
    public function store(Request $request)
    {
        $vorname = $request->input('vorname');
        $nachname = $request->input('nachname');
        $status = $request->input('status');
        $email = $request->input('email');
    }
}

When I access the API via POST request, I always get the error 404 - not found. Do you guys happen to have any idea what else could be wrong here?

Greetings.

0 likes
4 replies
tisuchi's avatar

@dsimon24cx What is the URL where you are sending the request?

Have you checked the right url/route name?

php artisan route:list
1 like
dsimon24cx's avatar

@tisuchi Yes. It is POST api/socm ...........socm.store › Api\SocialMediaController@store

Unfortunately, when I go to this URL, I still get the Error 404 error.

1 like

Please or to participate in this conversation.