When I try to create new users by Management API and some errors are happened, no errors occurred.
The API appears to be successful (the status code is 200).
I can check the errors only in Monitoring > Logs section.
I expect the API to return a failure status code (like 400) when something goes wrong.
What should I do?
Hi @t.fukao
Welcome back to the Auth0 Community!
Can you provide steps to reproduce this issue?
Thanks
Dawid
t.fukao
September 2, 2024, 1:02am
4
Thank you, @dawid.matuszczyk !
I’ve found my own mistake.
I’m using Auth0 Laravel SDK.
try {
Auth0::management()
->users()
->create(
connection: 'Username-Password-Authentication',
body: [
'name' => $request->name,
'email' => $request->email,
'password' => $request->password,
'email_verified' => true,
]
);
} catch (\Exception $e) {
logger($e->getMessage());
}
I realized that the following information is missing from the catch section.
return ['Fail!', Response::HTTP_INTERNAL_SERVER_ERROR];
I’m sorry for my elementary mistake.
t.fukao
September 2, 2024, 1:26am
5
@dawid.matuszczyk
I have an additional question.
How can I get the error message (e.g., “The user already exists.”) in the catch section?
t.fukao
September 19, 2024, 5:26am
6