Rest Users » History » Version 11
Jean-Baptiste Barth, 2013-05-06 22:49
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 | 10 | Jean-Baptiste Barth | Optional filters: |
16 | |||
17 | * @status@: get only users with the given status. See "app/models/principal.rb":/projects/redmine/repository/entry/trunk/app/models/principal.rb#L22-25 for a list of available statuses. Default is @1@ (active users) |
||
18 | * @name@: filter users on their login, firstname, lastname and mail ; if the pattern contains a space, it will also return users whose firstname match the first word or lastname match the second word. |
||
19 | * @group_id@: get only users who are members of the given group |
||
20 | |||
21 | 7 | Jean-Philippe Lang | h3. POST |
22 | 1 | Jean-Philippe Lang | |
23 | 7 | Jean-Philippe Lang | Creates a user. |
24 | 1 | Jean-Philippe Lang | |
25 | 7 | Jean-Philippe Lang | +Parameters+: |
26 | 1 | Jean-Philippe Lang | |
27 | 7 | Jean-Philippe Lang | * @user@ (required): a hash of the user attributes, including: |
28 | 1 | Jean-Philippe Lang | |
29 | 7 | Jean-Philippe Lang | * @login@ (required): the user login |
30 | * @password@: the user password |
||
31 | * @firstname@ (required) |
||
32 | * @lastname@ (required) |
||
33 | * @mail@ (required) |
||
34 | * @auth_source_id@: authentication mode id |
||
35 | 1 | Jean-Philippe Lang | |
36 | 7 | Jean-Philippe Lang | +Example+: |
37 | 1 | Jean-Philippe Lang | |
38 | 7 | Jean-Philippe Lang | <pre> |
39 | POST /users.xml |
||
40 | |||
41 | <?xml version="1.0" encoding="ISO-8859-1" ?> |
||
42 | <user> |
||
43 | <login>jplang</login> |
||
44 | <firstname>Jean-Philippe</firstname> |
||
45 | <lastname>Lang</lastname> |
||
46 | <password>secret</password> |
||
47 | <mail>jp_lang@yahoo.fr</mail> |
||
48 | <auth_source_id>2</auth_source_id> |
||
49 | </user> |
||
50 | </pre> |
||
51 | |||
52 | 8 | Lutz Horn | JSON |
53 | |||
54 | <pre> |
||
55 | { |
||
56 | "user": { |
||
57 | "login": "jplang", |
||
58 | "firstname": "Jean-Philippe", |
||
59 | "lastname": "Lang", |
||
60 | "mail": "jp_lang@yahoo.fr", |
||
61 | "password": "secret" |
||
62 | } |
||
63 | } |
||
64 | </pre> |
||
65 | |||
66 | 7 | Jean-Philippe Lang | +Response+: |
67 | |||
68 | * @201 Created@: user was created |
||
69 | * @422 Unprocessable Entity@: user was not created due to validation failures (response body contains the error messages) |
||
70 | |||
71 | h2. /users/:id.:format |
||
72 | |||
73 | h3. GET |
||
74 | |||
75 | Returns the user details. You can use @/users/current.:format@ for retrieving the user whose credentials are used to access the API. |
||
76 | |||
77 | 3 | Jean-Philippe Lang | +Parameters+: |
78 | 1 | Jean-Philippe Lang | |
79 | * @include@ (optional): a coma separated list of associations to include in the response: |
||
80 | |||
81 | 11 | Jean-Baptiste Barth | * @memberships@ : adds extra information about user's memberships and roles on the projects |
82 | * @groups@ (added in 2.1) : adds extra information about user's groups |
||
83 | 1 | Jean-Philippe Lang | |
84 | 7 | Jean-Philippe Lang | +Examples+: |
85 | 1 | Jean-Philippe Lang | |
86 | 7 | Jean-Philippe Lang | GET /users/current.xml |
87 | |||
88 | Returns the details about the current user. |
||
89 | |||
90 | 1 | Jean-Philippe Lang | GET /users/3.xml?include=memberships,groups |
91 | |||
92 | Returns the details about user ID 3, and additional detail about the user's project memberships. |
||
93 | |||
94 | +Reponse+: |
||
95 | |||
96 | <pre> |
||
97 | <user> |
||
98 | <id>3</id> |
||
99 | <login>jplang</login> |
||
100 | <firstname>Jean-Philippe</firstname> |
||
101 | <lastname>Lang</lastname> |
||
102 | <mail>jp_lang@yahoo.fr</mail> |
||
103 | <created_on>2007-09-28T00:16:04+02:00</created_on> |
||
104 | <last_login_on>2011-08-01T18:05:45+02:00</last_login_on> |
||
105 | 5 | Rick Mason | <custom_fields type="array" /> |
106 | 1 | Jean-Philippe Lang | <memberships type="array"> |
107 | 4 | Jean-Philippe Lang | <membership> |
108 | <project name="Redmine" id="1"/> |
||
109 | <roles type="array"> |
||
110 | <role name="Administrator" id="3"/> |
||
111 | <role name="Contributor" id="4"/> |
||
112 | 1 | Jean-Philippe Lang | </roles> |
113 | </membership> |
||
114 | 4 | Jean-Philippe Lang | </memberships> |
115 | <groups type="array"> |
||
116 | <group id="20" name="Developers"/> |
||
117 | </groups> |
||
118 | </user> |
||
119 | </pre> |
||
120 | |||
121 | 9 | Jean-Baptiste Barth | Depending on the status of the user who makes the request, you can get some more details: |
122 | * @api_key@ : the API key of the user, visible for admins and for yourself (added in 2.3.0) |
||
123 | * @status@ : a numeric id representing the status of the user, visible for admins only (added in 2.4.0). See "app/models/principal.rb":/projects/redmine/repository/entry/trunk/app/models/principal.rb#L22-25 for a list of available statuses. |
||
124 | |||
125 | 7 | Jean-Philippe Lang | h3. PUT |
126 | 4 | Jean-Philippe Lang | |
127 | 7 | Jean-Philippe Lang | Updates a user. |
128 | 4 | Jean-Philippe Lang | |
129 | 1 | Jean-Philippe Lang | +Example+: |
130 | |||
131 | 7 | Jean-Philippe Lang | PUT /users/20.xml |
132 | 1 | Jean-Philippe Lang | |
133 | +Parameters+: |
||
134 | |||
135 | * @user@ (required): a hash of the user attributes (same as for user creation) |
||
136 | |||
137 | 7 | Jean-Philippe Lang | h3. DELETE |
138 | 1 | Jean-Philippe Lang | |
139 | 7 | Jean-Philippe Lang | Deletes a user. |
140 | 4 | Jean-Philippe Lang | |
141 | 7 | Jean-Philippe Lang | +Example+: |
142 | 1 | Jean-Philippe Lang | |
143 | 7 | Jean-Philippe Lang | DELETE /users/20.xml |
144 | 1 | Jean-Philippe Lang | |
145 | +Response+: |
||
146 | 4 | Jean-Philippe Lang | |
147 | * @200 OK@: user was deleted |
||
148 | 7 | Jean-Philippe Lang | |
149 | h2. See also |
||
150 | |||
151 | * The [[Rest_Memberships|Memberships API]] for adding or removing a user from a project. |
||
152 | * The [[Rest_Groups|Groups API]] for adding or removing a user from a group. |