Rest Users » History » Version 4
Jean-Philippe Lang, 2011-08-01 18:34
| 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 | |||
| 27 | +Example+: |
||
| 28 | |||
| 29 | GET /users/3.xml?include=memberships |
||
| 30 | |||
| 31 | Returns the details about user ID 3, and additional detail about the user's project memberships. |
||
| 32 | |||
| 33 | +Reponse+: |
||
| 34 | |||
| 35 | <pre> |
||
| 36 | <user> |
||
| 37 | <id>3</id> |
||
| 38 | <login>jplang</login> |
||
| 39 | <firstname>Jean-Philippe</firstname> |
||
| 40 | <lastname>Lang</lastname> |
||
| 41 | <mail>jp_lang@yahoo.fr</mail> |
||
| 42 | <created_on>2007-09-28T00:16:04+02:00</created_on> |
||
| 43 | <last_login_on>2011-08-01T18:05:45+02:00</last_login_on> |
||
| 44 | <custom_fields type="array" /> |
||
| 45 | <memberships type="array"> |
||
| 46 | <membership> |
||
| 47 | <project name="Redmine" id="1"/> |
||
| 48 | <roles type="array"> |
||
| 49 | <role name="Administrator" id="3"/> |
||
| 50 | <role name="Contributor" id="4"/> |
||
| 51 | </roles> |
||
| 52 | </membership> |
||
| 53 | <membership> |
||
| 54 | </user> |
||
| 55 | </pre> |
||
| 56 | 2 | Bevan Rudge | |
| 57 | 1 | Jean-Philippe Lang | h2. Creating a user |
| 58 | |||
| 59 | POST /users.xml |
||
| 60 | |||
| 61 | Creates a user. |
||
| 62 | |||
| 63 | +Parameters+: |
||
| 64 | |||
| 65 | * @user@ (required): a hash of the user attributes, including: |
||
| 66 | |||
| 67 | * @login@ (required): the user login |
||
| 68 | * @password@: the user password |
||
| 69 | * @firstname@ (required) |
||
| 70 | * @lastname@ (required) |
||
| 71 | * @mail@ (required) |
||
| 72 | |||
| 73 | 4 | Jean-Philippe Lang | +Example+: |
| 74 | |||
| 75 | <pre> |
||
| 76 | POST /users.xml |
||
| 77 | |||
| 78 | <?xml version="1.0" encoding="ISO-8859-1" ?> |
||
| 79 | <user> |
||
| 80 | <login>jplang</login> |
||
| 81 | <firstname>Jean-Philippe</firstname> |
||
| 82 | <lastname>Lang</lastname> |
||
| 83 | <password>secret</password> |
||
| 84 | <mail>jp_lang@yahoo.fr</mail> |
||
| 85 | </user> |
||
| 86 | </pre> |
||
| 87 | |||
| 88 | 1 | Jean-Philippe Lang | +Response+: |
| 89 | |||
| 90 | * @201 Created@: user was created |
||
| 91 | * @422 Unprocessable Entity@: user was not created due to validation failures (response body contains the error messages) |
||
| 92 | |||
| 93 | h2. Updating a user |
||
| 94 | |||
| 95 | PUT /users/[id].xml |
||
| 96 | |||
| 97 | +Parameters+: |
||
| 98 | |||
| 99 | 4 | Jean-Philippe Lang | * @user@ (required): a hash of the user attributes (same as for user creation) |
| 100 | 1 | Jean-Philippe Lang | |
| 101 | Updates the user of given id. |
||
| 102 | |||
| 103 | h2. Deleting a user |
||
| 104 | |||
| 105 | 4 | Jean-Philippe Lang | DELETE /users/[id].xml |
| 106 | |||
| 107 | Deletes the user of given id. |
||
| 108 | |||
| 109 | +Response+: |
||
| 110 | |||
| 111 | * @200 OK@: user was deleted |