0

I'd like to create a new user in programmatically way, calling a webhook from a form of another website.

I added the route in web.php;

I added in the Controller a function copying the create function in RegisterController.php of Auth

public function add_user(Request $data)
{
    return User::create([
        'name' => $data['name'],
        'email' => $data['email'],
        'password' => Hash::make($data['password']),
    ]);
}

I added the route under $except of class VerifyCsrfToken

(even if is not working and I commented, just for testing, the

     // \App\Http\Middleware\VerifyCsrfToken::class,

in Kernel.php

but on online test tool I receive a "405 Method Not Allowed".

Any suggestion?

3
  • What's your route definition? Commented Jun 17, 2021 at 17:09
  • maybe you use wrong http method Commented Jun 17, 2021 at 17:25
  • very basic, Route::post('/add-user', 'HomeController@add_user')->name('add_user'); Commented Jun 17, 2021 at 18:51

1 Answer 1

1

In your routes file you are using Route::get() and then sending a post request. Try using Route::post() instead.

For testing you could use Route::any() to allow get and post requests.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.