Running into a wall with the genesyscloud Python SDK when trying to bulk-create agents from a CSV dump. The script reads the file, constructs a list of User objects, and loops through them calling users_api.post_users(user). It works fine for the first few rows, but then starts failing with a 422 Unprocessable Entity. The error payload is pretty vague: {'errors': [{'message': 'Invalid email address format', 'code': 'VALIDATION_ERROR'}]}. I’ve printed the raw string from the CSV before passing it to the User constructor, and it looks perfectly fine-standard user@domain.com format. No extra whitespace, no weird characters. The email field in the User object is being set via user.email = row['email']. I’m using Python 3.9 and the latest SDK version installed via pip. The weird part is that if I manually create the same user in the Genesys Cloud UI, it works instantly. The CSV is comma-separated, and I’m using the standard csv module to parse it. I’ve tried stripping the string with .strip() just in case there’s invisible carriage returns from Windows line endings, but that didn’t help. The timezone is set to America/Chicago in the user object, which matches our deployment region. I’m assuming the SDK is doing some hidden validation or serialization that’s mangling the input. Here’s the core loop:
for row in reader:
user = User()
user.first_name = row['firstName']
user.last_name = row['lastName']
user.email = row['email'].strip()
user.username = row['email'].strip()
user.password = row['password']
try:
users_api.post_users(user)
except ApiException as e:
print(f"Failed: {e.body}")
Is there a specific format the Python SDK expects for the email field that differs from the REST API? Or is this a known bug with the validation logic in the SDK wrapper? I’ve checked the OpenAPI spec, and it just says string with format email. Nothing about special encoding. The username field is also set to the email, which is required for unique identification. I can’t find any docs on bulk creation quirks in the Python SDK. It’s just failing silently in the logs until the exception hits. Any ideas on what’s triggering the validation error? I’ve tried escaping the @ symbol, but that broke it further. The CSV has about 50 rows, and it fails randomly, not on a specific row every time. That suggests it might be a rate limit or a threading issue, but I’m running it single-threaded. The script pauses for a second between requests. I’m out of ideas on what the SDK is doing under the hood that the direct API call isn’t.