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