Setting an array in user_metadata

I’m trying to set an array in user_metadata, but getting a payload validation error:

“Expected type object, null but found type array on property user_metadata”

However I can set an array to user_metadata directly from portal, and it saves successfully.
So, why can’t I do this from Management API, or is there a way to do it?

Hi @mithgroth,

Thanks for reaching out to the Auth0 Community!

Unfortunately, this is not possible. The user metadata is an Object Type, meaning that you will need to set the array as a property.

For example:

{
  "user_metadata": { 
    "fav_color" : ["blue", "red"]
  }
}

I recommend reading our Manage Metadata Using the Management API documentation for a walkthrough on updating user_metadata.

Please let me know if there’s anything else I can do to help.

Thanks,
Rueben

1 Like

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