I’m using cht create-users
to bulk create users in CHT where there already exists a list of users.
To tackle the issue of duplicate usernames, I first downloaded a list of existing users and then used it to validate the new list of users in csv to ensure that there are no duplicate usernames. I’m curious to know if there is a more efficient approach to solving this challenge.?
1 Like
We’re working on a feature release for bulk user creation which is being tracked by the GitHub issues #7503 and #7611. It has a POST /api/v2/users
route which accepts a csv body and it will create users from that csv. This route is consumed by the admin app that has a new button to access this feature.
While this is only available on the branch 3.15.0-FR-bulk-user-upload
for now, we’re planning to release it with CHT 4.0.
If the instance you’re using is on CHT v3.14.2 or higher, it already has a route that will bulk create users from a JSON array. cht-conf
hasn’t been updated to leverage this change yet but the route’s documentation is available here.
Here is an example response where a duplicate user is skipped and a second one is created successfully:
[
{
"error": {
"message": "Username \"duplicate-user\" already taken.",
"translationKey": "username.taken",
"translationParams": {
"username": "duplicate-user"
}
}
},
{
"contact": {
"id": "7aeaa4bc-ae5e-4964-8771-697209d2c6dd",
"rev": "4-d6119b98a4f32c4320ae12c83ed67bb2"
},
"user": {
"id": "org.couchdb.user:successful-user",
"rev": "1-1ea96917844a9020a0580e12eda28d2a"
},
"user-settings": {
"id": "org.couchdb.user:successful-user",
"rev": "1-b6e047bfc54dbb42ee07bb0ceff91cef"
}
}
]
1 Like
I will explore this on a local instance… This looks so much more efficient.
1 Like