How to create a user with Web Services API
search cancel

How to create a user with Web Services API

book

Article ID: 57526

calendar_today

Updated On:

Products

CA Agile Central On Premise (Rally) CA Agile Central SaaS (Rally)

Issue/Introduction

What is the payload to create a new user?

 

Resolution

The curl example below uses API Key authentication.

Follow the same syntax after replacing placeholder "zsessionid:<API Key - include the underscore before the key>" with a valid API Key of a user who has sufficient permissions (subscription or workspace admin) to create new users.
The payload must include required fields UserName and EmailAddress:

curl --header "zsessionid:<API Key - include the underscore before the key>" -H "Content-Type: application/json" -d"{\"User\":{\"UserName\":\"<User>@<Company.com>\",\"EmailAddress\":\"<User>@<Company.com>\"}}" https://rally1.rallydev.com/slm/webservice/v2.0/User/create

NOTE: Username must be unique.
Usernames are unique across the entire Rally stack.
An attempt to create a new user with a username that already exists results in the following error:

{"CreateResult": {"_rallyAPIMajor": "2", "_rallyAPIMinor": "0", "Errors": ["Validation error: User.UserName conflicts with <User>@<Company.com> ", "Validation error: User.UserName conflicts with <User>@<Company.com>"], "Warnings": []}}

NOTE: Required fields must be set in the payload.
An attempt to create a new user without email address (as in this wrong example):

curl --header "zsessionid:<API Key - include the underscore before the key>" -H "Content-Type: application/json" -d"{\"User\":{\"UserName\":\"<User>@<Company.com>\"}}" https://rally1.rallydev.com/slm/webservice/v2.0/User/create

results in the following error:

{"CreateResult": {"_rallyAPIMajor": "2", "_rallyAPIMinor": "0", "Errors": ["Validation error: User.EmailAddress should not be null"], "Warnings": []}}

If you want to create a user now but activate the user later, the payload can be modified to set?Disabled?attribute to?true:

curl --header "zsessionid:<API Key - include the underscore before the key>" -H "Content-Type: application/json" -d"{\"User\":{\"UserName\":\"<User>@<Company.com>\",\"EmailAddress\":\"<User>@<Company.com>\",\"Disabled\":\"true\"}}" https://rally1.rallydev.com/slm/webservice/v2.0/User/create

If the operation is successful a full JSON of the newly created user will be returned in the terminal.