addUser()

Pixelsilk API function to add a new user--requires the access-users permission
Parameters:
username: the new user's username (for logging in)
emailAddress: the new user's email address
firstName: the new user's first name
lastName: the new user's last name
password: the new user's password
roles: the new user's roles by id

Output:
The function addUser returns a site user object containing: id, name, username, emailAddress, firstName, lastName, roles.

Example:
In C#, write:
string username = "usernameOfUser";
string emailAddress = "emailAddressOfUser";
string firstName = "firstNameOfUser";
string lastName = "lastNameOfUser";
string password = "passwordOfUser";
Guid[] roles = <array of role id's>;
object newUser = AddUser(username, emailAddress, firstName, lastName, password, roles);
Note the capital first letter of the C# method.

HTTP Example:
Request Headers:
POST /api2/addUser HTTP/1.1
HOST: www.example.com
Content-Length: 368
Content-Type: application/x-www-form-urlencoded
Cookie: auth=0BE6A3F63D38...E773280B3565

Request Data:
Unencoded Data:
json={
   "username":"ExampleUser",
   "emailAddress":"user@example.com",
   "firstName":"Example",
   "lastName":"User",
   "password":"pw",
   "roles":[
      "28702460-372d-4815-a594-92b9864b1085"
   ]
}&token=7AdbNHZQBtwc...RPTEK8UvSUQ=

Url-encoded Data:
json=%7b%0d%0a+++...%5d%0d%0a%7d&token=7AdbNHZQBtwc...TEK8UvSUQ%3d

Response Headers:
HTTP/1.1 200 OK
Set-Cookie: auth=418F1D10EF09...566465D5A71; path=/
Content-Type: text/javascript; charset=UTF-8
Content-Length: 215

Response Data:
{"id":"04e39fbe-a494-48aa-b7d4-70932ab3602b",
"name":"Example User","username":"ExampleUser",
"emailAddress":"user@example.com","firstName":"Example",
"lastName":"User",
"roles":["28702460-372d-4815-a594-92b9864b1085"]}

JavaScript Example:
Method Call:
pixelsilk2.addUser(input, callback);

Input Object:
{
    username:"aduffy",
    emailAddress:"aduffy@example.com",
    firstName:"Albert",
    lastName:"Duffy",
    password:"Ab3d=f2i",
    roles:[
        "37be009a-472a-47b7-8d5c-c2dcd5c9ebb5"
    ]
}

Returned Data:
{
    "id":"ede489d4-39b9-40c8-bd7a-20c1fd8288fc",
    "name":"Albert Duffy",
    "username":"aduffy",
    "emailAddress":"aduffy@example.com",
    "firstName":"Albert",
    "lastName":"Duffy",
    "roles":[
        "37be009a-472a-47b7-8d5c-c2dcd5c9ebb5"
    ]
}

Back to Users »