Rest Users » History » Version 18
Toshi MARUYAMA, 2017-05-12 05:46
code highlight
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 | 13 | Go MAEDA | * @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). Possible values are: |
18 | ** @1@: Active (User can login and use their account) |
||
19 | ** @2@: Registered (User has registered but not yet confirmed their email address or was not yet activated by an administrator. User can not login) |
||
20 | ** @3@: Locked (User was once active and is now locked, User can not login) |
||
21 | 10 | Jean-Baptiste Barth | * @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. |
22 | * @group_id@: get only users who are members of the given group |
||
23 | |||
24 | 7 | Jean-Philippe Lang | h3. POST |
25 | 1 | Jean-Philippe Lang | |
26 | 7 | Jean-Philippe Lang | Creates a user. |
27 | 1 | Jean-Philippe Lang | |
28 | 7 | Jean-Philippe Lang | +Parameters+: |
29 | 1 | Jean-Philippe Lang | |
30 | 7 | Jean-Philippe Lang | * @user@ (required): a hash of the user attributes, including: |
31 | 1 | Jean-Philippe Lang | |
32 | 7 | Jean-Philippe Lang | * @login@ (required): the user login |
33 | * @password@: the user password |
||
34 | * @firstname@ (required) |
||
35 | * @lastname@ (required) |
||
36 | * @mail@ (required) |
||
37 | * @auth_source_id@: authentication mode id |
||
38 | 12 | Matt Wiseley | * @mail_notification@: only_my_events, none, etc. |
39 | * @must_change_passwd@: true or false |
||
40 | 15 | Go MAEDA | * @send_information@: true of false : Send acocunt information to the user |
41 | 1 | Jean-Philippe Lang | |
42 | 7 | Jean-Philippe Lang | +Example+: |
43 | 1 | Jean-Philippe Lang | |
44 | 17 | Toshi MARUYAMA | <pre> |
45 | 7 | Jean-Philippe Lang | POST /users.xml |
46 | 17 | Toshi MARUYAMA | </pre> |
47 | 1 | Jean-Philippe Lang | |
48 | 16 | Toshi MARUYAMA | <pre><code class="xml"> |
49 | 7 | Jean-Philippe Lang | <?xml version="1.0" encoding="ISO-8859-1" ?> |
50 | <user> |
||
51 | <login>jplang</login> |
||
52 | <firstname>Jean-Philippe</firstname> |
||
53 | <lastname>Lang</lastname> |
||
54 | <password>secret</password> |
||
55 | <mail>jp_lang@yahoo.fr</mail> |
||
56 | <auth_source_id>2</auth_source_id> |
||
57 | </user> |
||
58 | 16 | Toshi MARUYAMA | </code></pre> |
59 | 7 | Jean-Philippe Lang | |
60 | 8 | Lutz Horn | JSON |
61 | |||
62 | 16 | Toshi MARUYAMA | <pre><code class="json"> |
63 | 8 | Lutz Horn | { |
64 | "user": { |
||
65 | "login": "jplang", |
||
66 | "firstname": "Jean-Philippe", |
||
67 | "lastname": "Lang", |
||
68 | "mail": "jp_lang@yahoo.fr", |
||
69 | "password": "secret" |
||
70 | } |
||
71 | } |
||
72 | 16 | Toshi MARUYAMA | </code></pre> |
73 | 8 | Lutz Horn | |
74 | 7 | Jean-Philippe Lang | +Response+: |
75 | |||
76 | * @201 Created@: user was created |
||
77 | * @422 Unprocessable Entity@: user was not created due to validation failures (response body contains the error messages) |
||
78 | |||
79 | h2. /users/:id.:format |
||
80 | |||
81 | h3. GET |
||
82 | |||
83 | Returns the user details. You can use @/users/current.:format@ for retrieving the user whose credentials are used to access the API. |
||
84 | |||
85 | 3 | Jean-Philippe Lang | +Parameters+: |
86 | 1 | Jean-Philippe Lang | |
87 | * @include@ (optional): a coma separated list of associations to include in the response: |
||
88 | |||
89 | 11 | Jean-Baptiste Barth | * @memberships@ : adds extra information about user's memberships and roles on the projects |
90 | * @groups@ (added in 2.1) : adds extra information about user's groups |
||
91 | 1 | Jean-Philippe Lang | |
92 | 7 | Jean-Philippe Lang | +Examples+: |
93 | 1 | Jean-Philippe Lang | |
94 | 7 | Jean-Philippe Lang | GET /users/current.xml |
95 | |||
96 | Returns the details about the current user. |
||
97 | |||
98 | 1 | Jean-Philippe Lang | GET /users/3.xml?include=memberships,groups |
99 | |||
100 | Returns the details about user ID 3, and additional detail about the user's project memberships. |
||
101 | |||
102 | 18 | Toshi MARUYAMA | +Response+: |
103 | 1 | Jean-Philippe Lang | |
104 | 18 | Toshi MARUYAMA | <pre><code class="xml"> |
105 | 1 | Jean-Philippe Lang | <user> |
106 | <id>3</id> |
||
107 | <login>jplang</login> |
||
108 | <firstname>Jean-Philippe</firstname> |
||
109 | <lastname>Lang</lastname> |
||
110 | <mail>jp_lang@yahoo.fr</mail> |
||
111 | <created_on>2007-09-28T00:16:04+02:00</created_on> |
||
112 | <last_login_on>2011-08-01T18:05:45+02:00</last_login_on> |
||
113 | 14 | Go MAEDA | <api_key>ebc3f6b781a6fb3f2b0a83ce0ebb80e0d585189d</api_key> |
114 | <status>1</status> |
||
115 | 5 | Rick Mason | <custom_fields type="array" /> |
116 | 1 | Jean-Philippe Lang | <memberships type="array"> |
117 | 4 | Jean-Philippe Lang | <membership> |
118 | <project name="Redmine" id="1"/> |
||
119 | <roles type="array"> |
||
120 | <role name="Administrator" id="3"/> |
||
121 | <role name="Contributor" id="4"/> |
||
122 | 1 | Jean-Philippe Lang | </roles> |
123 | </membership> |
||
124 | 4 | Jean-Philippe Lang | </memberships> |
125 | <groups type="array"> |
||
126 | <group id="20" name="Developers"/> |
||
127 | </groups> |
||
128 | </user> |
||
129 | 18 | Toshi MARUYAMA | </code></pre> |
130 | 4 | Jean-Philippe Lang | |
131 | 9 | Jean-Baptiste Barth | Depending on the status of the user who makes the request, you can get some more details: |
132 | * @api_key@ : the API key of the user, visible for admins and for yourself (added in 2.3.0) |
||
133 | * @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. |
||
134 | |||
135 | 7 | Jean-Philippe Lang | h3. PUT |
136 | 4 | Jean-Philippe Lang | |
137 | 7 | Jean-Philippe Lang | Updates a user. |
138 | 4 | Jean-Philippe Lang | |
139 | 1 | Jean-Philippe Lang | +Example+: |
140 | |||
141 | 7 | Jean-Philippe Lang | PUT /users/20.xml |
142 | 1 | Jean-Philippe Lang | |
143 | +Parameters+: |
||
144 | |||
145 | * @user@ (required): a hash of the user attributes (same as for user creation) |
||
146 | |||
147 | 7 | Jean-Philippe Lang | h3. DELETE |
148 | 1 | Jean-Philippe Lang | |
149 | 7 | Jean-Philippe Lang | Deletes a user. |
150 | 4 | Jean-Philippe Lang | |
151 | 7 | Jean-Philippe Lang | +Example+: |
152 | 1 | Jean-Philippe Lang | |
153 | 7 | Jean-Philippe Lang | DELETE /users/20.xml |
154 | 1 | Jean-Philippe Lang | |
155 | +Response+: |
||
156 | 4 | Jean-Philippe Lang | |
157 | * @200 OK@: user was deleted |
||
158 | 7 | Jean-Philippe Lang | |
159 | h2. See also |
||
160 | |||
161 | * The [[Rest_Memberships|Memberships API]] for adding or removing a user from a project. |
||
162 | * The [[Rest_Groups|Groups API]] for adding or removing a user from a group. |