How to create a user with Web Services API

Document ID : KB000057526
Last Modified Date : 14/02/2018
Show Technical Document Details

Issue

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 _abc123 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:_abc123" -H "Content-Type: application/json" -d"{\"User\":{\"UserName\":\"nicktemp123@wsapi.com\",\"EmailAddress\":\"validemail@domain.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 nicktemp123@wsapi.com ", "Validation error: User.UserName conflicts with nicktemp123@wsapi.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:_abc123" -H "Content-Type: application/json" -d"{\"User\":{\"UserName\":\"nicktemp777@wsapi.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:_abc123" -H "Content-Type: application/json" -d"{\"User\":{\"UserName\":\"nicktemp5@wsapi.com\",\"EmailAddress\":\"validemail@domain.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.
Here is a screenshot form the UI ?(Setup>Users tab) that shows the new user:

User-added image