I’m trying to automate some onboarding tasks by reading a CSV file and using the Genesys Cloud Python SDK to create users in bulk. The script reads the file fine, but when I loop through the rows and call users_api.post_users, I keep hitting a 400 Bad Request error.
Here’s the snippet I’m using:
from genesyscloud import users_api
for row in csv_data:
body = users_api.UserCreateRequest(
email=row['email'],
name=row['name'],
username=row['username'],
user_type='agent'
)
try:
users_api.post_users(body=body)
print(f"Created user: {row['name']}")
except Exception as e:
print(f"Error creating {row['name']}: {e}")
The error message just says Validation failed. I’ve checked the CSV and the emails are valid. I’m wondering if I need to set a specific division ID or if the user_type enum is wrong. The docs are a bit vague on required fields for the UserCreateRequest. Does anyone have a working example of this? I’m running this in a local Python environment with the latest SDK version. It’s probably something simple I’m missing.