# Sandbox Error: undefined when creating a user using Management API

**URL:** <https://community.auth0.com/t/sandbox-error-undefined-when-creating-a-user-using-management-api/99259>\
**Category:** Get Help\
**Tags:** users, management-api\
**Created:** [January 30, 2023, 8:40am UTC](https://community.auth0.com/t/sandbox-error-undefined-when-creating-a-user-using-management-api/99259 "2023-01-30T08:40:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hillary.datoc.ns](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/hillary.datoc.ns/32/42957_2.png) [@hillary.datoc.ns](https://community.auth0.com/u/hillary.datoc.ns)\
**Post date:** [January 30, 2023, 8:40am UTC](https://community.auth0.com/t/sandbox-error-undefined-when-creating-a-user-using-management-api/99259/1 "2023-01-30T08:40:08Z")

</div>

Hello and Good day!

We are trying to create a user using the Management API while connected using a Custom Database with the `Import Users to Auth0` option enabled. When looking at the other similar questions, they all solved their issues by taking a look at their action database scripts for create user. However, since we have the `Import Users` option on, only the login and getUser scripts are accessible. I can post the two scripts if need be, but using the save and try function, both are correctly returning the user details from the legacy DB.

How can we further move forward with this issue?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![hillary.datoc.ns](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/hillary.datoc.ns/32/42957_2.png) [@hillary.datoc.ns](https://community.auth0.com/u/hillary.datoc.ns)\
**Post date:** [January 30, 2023, 9:07am UTC](https://community.auth0.com/t/sandbox-error-undefined-when-creating-a-user-using-management-api/99259/2 "2023-01-30T09:07:06Z")

</div>

I was able to solve it, it DID have something to do with the database scripts, particularly the getUser script.

Instead of  
`if (err || result.rows.length === 0) { return callback(err || new WrongUsernameOrPasswordError(email)); }`

We changed it to  
`if (err || result.rows.length === 0) return callback(err);`

And the create user requests started working 👍

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [January 30, 2023, 9:36am UTC](https://community.auth0.com/t/sandbox-error-undefined-when-creating-a-user-using-management-api/99259/3 "2023-01-30T09:36:23Z")

</div>

Wooohooo perfect and thanks for sharing that with the rest of community!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [February 13, 2023, 9:36am UTC](https://community.auth0.com/t/sandbox-error-undefined-when-creating-a-user-using-management-api/99259/4 "2023-02-13T09:36:58Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
