Traceback (most recent call last):
File “create_users.py”, line 24, in
response = user_api.post_users(body=user_body)
genesiscloud.platform.client.rest.ApiException: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({‘Content-Type’: ‘application/json’, …})
HTTP response body: {“errors”:[{“code”:“invalidRequest”,“message”:“User name is required.”}]}
I’m trying to bulk create users from a CSV using the Python SDK. The script reads the file, builds the User object, and calls post_users. The first user creates fine. The second fails with a 400 error claiming name is missing. I’ve printed user_body right before the call. It looks correct.
import csv
from genesiscloud.platform.client import UsersApi
api = UsersApi()
with open('users.csv') as f:
reader = csv.DictReader(f)
for row in reader:
user_body = {
'name': row['Name'],
'email': row['Email'],
'division_id': 'default'
}
print(user_body)
try:
api.post_users(body=user_body)
except Exception as e:
print(e)
break
The CSV has headers Name and Email. The values are strings. No extra whitespace. I’ve checked the encoding. It’s UTF-8. The SDK version is the latest. Why is it rejecting the second request with a name error when the print output shows the name is there?