Bulk import users json file

I’m trying to run a bulk user import with upsert set to true to update user’s app metadata. I’m getting code 200 from the endpoint indicating that the job was successful, but the summary is indicating that all the imports failed.

[
   {
      "email": "testuser@gmail.com",
      "app_metadata": {
         "onboarded": "2020-01-01",
         "username": "testuser"
      }
   }
]

But the bulk import keeps failing. I’m using the auth0 python sdk as follows, where I first get the token using

token = GetToken(...).client_credentials(..)["access_token"]

then create the auth0 instance with

auth0 = Auth0(domain, token)

and finally run the bulk import with

auth0.jobs.import_users(connection_id, file_obj, upsert = True)

Hi @zaki.machfj ,

Welcome to the Auth0 Community!

I understand that you want to update the user’s metadata. Regarding the 200 code from the user import job, if the import file has a valid JSON format, this job will be successful, but that does not mean the user has been imported successfully.

I tested this issue and noticed that by replacing app_metadata with user_metadata the user is created/updated successfully.

[
   {
      "email": "testuser@gmail.com",
      "user_metadata": {
         "onboarded": "2020-01-01",
         "username": "testuser"
      }
   }
]

This article explains the difference between user_metadata and app_metadata. Looks to me onboarded and username are user attributes and should be stored under user_metadata.

Can you give it a try? Please let me know how it goes or if any further queries about this topic. Thanks!

Hi Lihua,

Thank you for the reply. The issue was indeed that username was a part of app_metadata which auth0 prohibits, however I couldn’t move it to user_metadata because we need username in user_metadata for some particular use-cases. I chose to loop over the users and run individual patch requests instead, which worked.

Thank you so much for the reply!

1 Like