Skip to main content
Version: QB90

Interact with Users

Get all users in the system

Syntax

Users in the system can be accessed using http GET method through below url:

http://localhost:8810/rest/users

The response is of mime type application/xml and the content is XML representation of all users in the system.

Security

You will need to use http BASIC authentication to login as authorized QuickBuild user if the anonymous does not have adminstrative right.

Demo

Below curl command demonstrates how to get all users:

curl -u admin:admin http://localhost:8810/rest/users

Access user by id

Syntax

User can be accessed by id using http GET method through below url:

http://localhost:8810/rest/users/<user id>

The response is of mime type application/xml and the content is XML representation of the user.

Security

You will need to use http BASIC authentication to login as authorized QuickBuild user if the anonymous does not have adminstrative right.

Demo

Below curl command demonstrates how to get user of id 1:

curl -u admin:admin http://localhost:8810/rest/users/1

Get user display name by id

Syntax

User display name can be accessed by id using http GET method through below url:

http://localhost:8810/rest/users/<user id>/display_name

The response is of mime type text/plain and the content is string representation of the user.

Security

You will need to use http BASIC authentication to login as authorized QuickBuild user if the anonymous does not have adminstrative right.

Demo

Below curl command demonstrates how to get display name of user with id 1:

curl -u admin:admin http://localhost:8810/rest/users/1/display_name

Update user

Syntax

User can be updated by posting XML representation of the user to below url:

http://localhost:8810/rest/users

Normally you do not need to create the xml from scratch: you may retrieve XML representation of the user using http GET method, modify certain parts of the XML and post back to above url.

The response is of mime type text/plain and the content is string representation of the user id being updated.

warning

If you want to change user password, please remove the "secret=hash" attribute from the password element and replace the element text with a plain text password; otherwise, QuickBuild will think that the supplied password has already been hashed.

Security

You will need to use http BASIC authentication to login as administrator if the anonymous does not have administrative right.

Demo

We will use curl to demonstrate how to modify password of user robin to be 12345:

  1. Retrieve id of user robin using id service:

    curl http://localhost:8810/rest/ids?user_name=robin

    Assume returned id is 2.

  2. Retrieve XML representation of user robin into a temp file using below command:

    curl -u admin:admin http://localhost:8810/rest/users/2 > tempfile.xml
  3. Edit tempfile.xml to set content of password element as 12345 , and remove attribute secret="hash" . The password element should look like below after modification:

    <password>12345</password>
  4. Post back modified content using below command:

    curl -X POST -u admin:admin -d@tempfile.xml http://localhost:8810/rest/users

Create user

Syntax

User can be created by posting XML representation of the user to below url:

http://localhost:8810/rest/users

Please note that the posted XML should NOT contain the id element; otherwise, QuickBuild will treat the post as an update to the user with that id.

Normally you do not need to create the XML from scratch: you may retrieve XML representation of a templating user using http GET method, remove the id element, modify certain parts and post back to above url.

The response is of mime type text/plain and the content is string representation of the newly created user id.

warning

The password element will contain the attribute "secret" when retrieve the XML representation of an existing user. This attribute should be removed when a new user is created. This tells QuickBuild that the password is in plain text form and should be hashed. However, if you are creating user by copying existing one and want to remain the password, the "secret" attribute should then be preserved.

Security

You will need to use http BASIC authentication to login as administrator if the anonymous does not have administrative rights.

Demo

We will use curl to demonstrate how to create a new user robin by copying the existing user admin , and change the password to 12345.

  1. Get id of user admin with id service

    curl http://localhost/rest/ids?user_name=admin

    Assume returned id is 1.

  2. Retrieve XML representation of user admin into a temp file using below command:

    curl -u admin:admin http://localhost:8810/rest/users/1 > tempfile.xml
  3. Edit tempfile.xml to do the following:

    1. Remove the id element.
    2. Change content of the name element to be robin.
    3. Change content of password element to be 12345.
    4. Remove attribute secret="hash" from the password element.
  4. Post back modified content using below command:

    curl -X POST -u admin:admin -d@tempfile.xml http://localhost:8810/rest/users

Delete user

Syntax

User can be deleted using http DELETE method through below url:

http://localhost:8810/rest/users/<user id>

Here <user id} stands for id of the user to be deleted.

Security

You will need to use http BASIC authentication to login as administrator if the anonymous does not have administrative right.

Demo

Below curl command demonstrates how to delete the user with id 2:

curl -X DELETE -u admin:admin http://localhost:8810/rest/users/2