Rest Users » History » Version 6
  Jean-Philippe Lang, 2012-06-03 15:19 
  add groups association
| 1 | 1 | Jean-Philippe Lang | h1. Users | 
|---|---|---|---|
| 2 | |||
| 3 | 3 | Jean-Philippe Lang | {{>toc}} | 
| 4 | |||
| 5 | 1 | Jean-Philippe Lang | h2. Listing users | 
| 6 | |||
| 7 | GET /users.xml | ||
| 8 | |||
| 9 | Returns users. | ||
| 10 | |||
| 11 | h2. Showing a user | ||
| 12 | |||
| 13 | GET /users/[id].xml | ||
| 14 | |||
| 15 | Returns the user of given id. | ||
| 16 | |||
| 17 | GET /users/current.xml | ||
| 18 | |||
| 19 | Returns the user whose credentials are used to access the API. | ||
| 20 | |||
| 21 | 3 | Jean-Philippe Lang | +Parameters+: | 
| 22 | 1 | Jean-Philippe Lang | |
| 23 | 3 | Jean-Philippe Lang | * @include@ (optional): a coma separated list of associations to include in the response: | 
| 24 | |||
| 25 | * @memberships@ | ||
| 26 | 6 | Jean-Philippe Lang | * @groups@ (added in 2.1) | 
| 27 | 3 | Jean-Philippe Lang | |
| 28 | +Example+: | ||
| 29 | 1 | Jean-Philippe Lang | |
| 30 | 6 | Jean-Philippe Lang | GET /users/3.xml?include=memberships,groups | 
| 31 | 3 | Jean-Philippe Lang | |
| 32 | Returns the details about user ID 3, and additional detail about the user's project memberships. | ||
| 33 | |||
| 34 | +Reponse+: | ||
| 35 | |||
| 36 | <pre> | ||
| 37 | <user> | ||
| 38 | <id>3</id> | ||
| 39 | <login>jplang</login> | ||
| 40 | <firstname>Jean-Philippe</firstname> | ||
| 41 | <lastname>Lang</lastname> | ||
| 42 | <mail>jp_lang@yahoo.fr</mail> | ||
| 43 | <created_on>2007-09-28T00:16:04+02:00</created_on> | ||
| 44 | <last_login_on>2011-08-01T18:05:45+02:00</last_login_on> | ||
| 45 | <custom_fields type="array" /> | ||
| 46 | <memberships type="array"> | ||
| 47 | <membership> | ||
| 48 | <project name="Redmine" id="1"/> | ||
| 49 | <roles type="array"> | ||
| 50 | <role name="Administrator" id="3"/> | ||
| 51 | <role name="Contributor" id="4"/> | ||
| 52 | 1 | Jean-Philippe Lang | </roles> | 
| 53 | </membership> | ||
| 54 | 6 | Jean-Philippe Lang | </memberships> | 
| 55 | <groups type="array"> | ||
| 56 | <group id="20" name="Developers"/> | ||
| 57 | </groups> | ||
| 58 | 3 | Jean-Philippe Lang | </user> | 
| 59 | </pre> | ||
| 60 | 2 | Bevan Rudge | |
| 61 | 1 | Jean-Philippe Lang | h2. Creating a user | 
| 62 | |||
| 63 | POST /users.xml | ||
| 64 | |||
| 65 | Creates a user. | ||
| 66 | |||
| 67 | +Parameters+: | ||
| 68 | |||
| 69 | * @user@ (required): a hash of the user attributes, including: | ||
| 70 | |||
| 71 | * @login@ (required): the user login | ||
| 72 | * @password@: the user password | ||
| 73 | * @firstname@ (required) | ||
| 74 | * @lastname@ (required) | ||
| 75 | * @mail@ (required) | ||
| 76 | 5 | Rick Mason | * @auth_source_id@: authentication mode id | 
| 77 | 1 | Jean-Philippe Lang | |
| 78 | 4 | Jean-Philippe Lang | +Example+: | 
| 79 | |||
| 80 | <pre> | ||
| 81 | POST /users.xml | ||
| 82 | |||
| 83 | <?xml version="1.0" encoding="ISO-8859-1" ?> | ||
| 84 | <user> | ||
| 85 | <login>jplang</login> | ||
| 86 | <firstname>Jean-Philippe</firstname> | ||
| 87 | <lastname>Lang</lastname> | ||
| 88 | <password>secret</password> | ||
| 89 | <mail>jp_lang@yahoo.fr</mail> | ||
| 90 | 5 | Rick Mason | <auth_source_id>2</auth_source_id> | 
| 91 | 4 | Jean-Philippe Lang | </user> | 
| 92 | </pre> | ||
| 93 | |||
| 94 | 1 | Jean-Philippe Lang | +Response+: | 
| 95 | |||
| 96 | * @201 Created@: user was created | ||
| 97 | * @422 Unprocessable Entity@: user was not created due to validation failures (response body contains the error messages) | ||
| 98 | |||
| 99 | h2. Updating a user | ||
| 100 | |||
| 101 | PUT /users/[id].xml | ||
| 102 | |||
| 103 | +Parameters+: | ||
| 104 | |||
| 105 | 4 | Jean-Philippe Lang | * @user@ (required): a hash of the user attributes (same as for user creation) | 
| 106 | 1 | Jean-Philippe Lang | |
| 107 | Updates the user of given id. | ||
| 108 | |||
| 109 | h2. Deleting a user | ||
| 110 | |||
| 111 | 4 | Jean-Philippe Lang | DELETE /users/[id].xml | 
| 112 | |||
| 113 | Deletes the user of given id. | ||
| 114 | |||
| 115 | +Response+: | ||
| 116 | |||
| 117 | * @200 OK@: user was deleted |