NiceCxoneSdkClientError: (422) Conflict
Reason: Unprocessable Entity
Detail: The email address is already in use.
Trying to bulk create users from a CSV using the Python SDK. I’ve got a list of 500 agents to onboard. The script loops through the rows, builds a User object, and calls users_api.create_user(user). It works for the first 20 or so, then hits a 422.
I assumed the email was unique in the system, but maybe there’s a race condition or a hidden duplicate in the CSV I missed. The error doesn’t give me the specific email that failed, just the generic conflict message. I’m catching the exception and logging the row index, but I need to know which user caused the crash to skip it and continue.
Here’s the loop structure:
for row in csv_reader:
user = User(
email=row['email'],
name=row['name'],
email_enabled=True,
username=row['username']
)
try:
users_api.create_user(user=user)
except NiceCxoneSdkClientError as e:
print(f"Failed at row {row['id']}: {e}")
continue
The SDK wrapper swallows the detailed response body sometimes. Is there a way to extract the specific field error from the NiceCxoneSdkClientError object? Or should I be using a different endpoint for bulk operations? The standard create_user feels too slow for this volume anyway. I’ve tried adding a time.sleep(0.5) between calls, but the 422 still hits. The CSV is clean, I checked it manually. No duplicate emails in the source file.
Maybe the API is case-sensitive on email and I have a mismatch? Or is it checking against a global pool including disabled users? I can’t find docs on the exact validation logic for bulk imports via SDK. Just getting stuck on this error and can’t proceed with the rest of the batch.