Payload validation error on updating user

Hi there,

I’m trying to update a user with the Management API (nodeJS) but I always get a bad request error. It looks like all the user’s fields are required. However, I just want to update the email and I am passing to the method only the email field. Is this wrong? Do I have to pass the unchanged data too?

This is my code:

const { ManagementClient } = require('auth0')    
const management = new ManagementClient({
      domain: auth0Domain,
      clientId: auth0WebsiteBackendId,
      clientSecret: auth0WebsiteBackendSecret,
    })
const result = await management.users.update({ id: userId }, { email })

And this is the error I got in the catch block:

Bad Request: Payload validation error: 'None of the valid schemas were met'. Inner errors: [ Payload validation error: 'Missing required property: blocked'. (also) Payload validation error: 'Missing required property: email_verified'. (also) Payload validation error: 'Missing required property: email'. (also) Payload validation error: 'Missing required property: verify_email'. (also) Payload validation error: 'Missing required property: phone_number'. (also) Payload validation error: 'Missing required property: phone_verified'. (also) Payload validation error: 'Missing required property: verify_phone_number'. (also) Payload validation error: 'Missing required property: password'.
    (also) Payload validation error: 'Missing required property: verify_password'. (also) Payload validation error: 'Missing required property: user_metadata'. (also) Payload validation error: 'Missing required property: app_metadata'. (also) Payload validation error: 'Missing required property: username'. (also) Payload validation error: 'Missing required property: client_id'. (also) Payload validation error: 'Missing required property: given_name'. (also) Payload validation error: 'Missing required property: family_name'. (also) Payload validation error: 'Missing
    required property: picture'. (also) Payload validation error: 'Missing required property: name'. (also) Payload validation error: 'Missing required property: nickname'. ].v
2 Likes

Hello, Welcome to Auth0 Community!

All properties are required to change one of them. This is because when you use a PATCH method updating a user, as it says in here, if you only pass the property you want to update, you would be deleting the rest of them, and that is not allowed in Auth0.

If you want to update users, make sure to always pass all the user profile properties otherwise it will throw you an error.

I hope this helps to answer your queries.

Thank you!

Hi Karen

This is actually incorrect - you CAN specify only one property, and will patch only this one. I just verified this by testing the Management API directly by patching this:

PATCH https://{{auth0_domain}}/api/v2/users/:id

{
    "family_name": "ParkerX"
}

This did only replace the family_name of my account.

This was also working for me using the Auth0 node library until recently using the node packages, so something must have changed to break those.

Patching works again for us, this was invalid data on our end. @mararrdeveloper, we saw this only occurring if an empty payload was submitted.

did u manage to make it work with auth0 npm ?

getting exact same error

“message”: “Payload validation error: ‘None of the valid schemas were met’. Inner errors: [ Payload validation error: ‘Missing required property: blocked’. (also) Payload validation error: ‘Missing required property: email_verified’. (also) Payload validation error: ‘Missing required property: email’. (also) Payload validation error: ‘Missing required property: verify_email’. (also) Payload validation error: ‘Missing required property: phone_number’. (also) Payload validation error: ‘Missing required property: phone_verified’. (also) Payload validation error: ‘Missing required property: verify_phone_number’. (also) Payload validation error: ‘Missing required property: password’. (also) Payload validation error: ‘Missing required property: verify_password’. (also) Payload validation error: ‘Missing required property: user_metadata’. (also) Payload validation error: ‘Missing required property: app_metadata’. (also) Payload validation error: ‘Missing required property: username’. (also) Payload validation error: ‘Missing required property: client_id’. (also) Payload validation error: ‘Missing required property: given_name’. (also) Payload validation error: ‘Missing required property: family_name’. (also) Payload validation error: ‘Missing required property: picture’. (also) Payload validation error: ‘Missing required property: name’. (also) Payload validation error: ‘Missing required property: nickname’. ].”,

this does not work with the auth0 npm