Exporting user_metadata or app_metadata are empty

Hello! I’m trying to export my users, including a few fields that are inside app_metadata and user_metadata, but the downloaded CSV doesn’t include them.

When I look into my users → raw JSON to verify the info is there, I can clearly see the user_metadata.groups being an array of strings.

This is an example, but I couldn’t make it work with any of the fields inside app_metadata or user_metadata.

Thanks!

Hi @antonio.acuna

Welcome to the Auth0 Community!

Thank you for posting your question. If you are exporting users in the CSV format you have to provide the full path to the object for the export:

{
//rest of user profile...
"app_metadata": {
   "address": {
      "street_address": {
          "number": "1",
      }
   }
}

To get the number attribute value exported the field would need to be specified like below:

{
"connection_id": "<connection ID here",
"format": "csv",
"fields": [
{
"name": "user_id"
},
{
"name": "username"
},
{
"name": "app_metadata.address.street_address.number"
}
]
}

Alternatively, you can use the JSON object instead of the CSV to export the entire object or the list by just requesting the app_metadata/user_metadata.

You can read more about that here → Fields that can be Exported using the Bulk Export Tool

Thanks
Dawid

Hello @dawid.matuszczyk , I’m using the User Import / Export extension.

And yes, I’m using the full path. In my case is:

{
// raw JSON from user
"user_metadata": {
        "groups": [
            "group_1",
            "group_2",
            "group_3"
        ]
    },
}

And in the Export tool, I use:

User Attribute → Field Name
email → Email
identities[0].connection → Connection
last_login → Last Login
user_metadata.groups → Groups

Thank you for the reply, @antonio.acuna. Can you try to export the users with the POST /API/v2/jobs/users-exports? https://auth0.com/docs/manage-users/user-migration/bulk-user-exports. I want to identify if that’s an issue on the extension side or maybe a misconfiguration.

Thanks
Dawid

Hello again @dawid.matuszczyk

I tried with the API using:

--data '{"connection_id": "con_5Ub8BzBuwK24SpbB", "format": "csv", "limit": 5, "fields": [{"name": "email"}, { "name": "identities[0].connection", "export_as": "provider" }, { "name": "last_login" }, { "name": "user_metadata.groups"}, { "name": "groups"}]}'

But both user_metadata.groups and groups where empty but if you access an index of the array it works:

--data '{"connection_id": "con_5Ub8BzBuwK24SpbB", "format": "csv", "limit": 5, "fields": [{"name": "email"}, { "name": "identities[0].connection", "export_as": "provider" }, { "name": "last_login" }, { "name": "user_metadata.groups[0]"}, { "name": "groups[0]"}]}'

Obviously, it’s not the expected behaviour but probably a hint to understand the issue. Also, the json version fill the fields correctly using both versions so this array issue is something that only happens with CSV exports.

Hi @antonio.acuna

Thank you for the reply. For the confirmation, if you access the index of the array, does the export return the whole array or only the value from the first index?

I will talk with the team internally to better understand the behaviour behind the CSV export.

Thanks
Dawid

Hi @dawid.matuszczyk using CSV export if I access the index of the array I get returned the value on that index, not the whole array. I didn’t try using JSON export.

1 Like