Rest Users » History » Version 18
Toshi MARUYAMA, 2017-05-12 05:46
code highlight
1 | 1 | Jean-Philippe Lang | h1. Users |
---|---|---|---|
2 | 1 | Jean-Philippe Lang | |
3 | 3 | Jean-Philippe Lang | {{>toc}} |
4 | 3 | Jean-Philippe Lang | |
5 | 7 | Jean-Philippe Lang | h2. /users.:format |
6 | 1 | Jean-Philippe Lang | |
7 | 7 | Jean-Philippe Lang | h3. GET |
8 | 7 | Jean-Philippe Lang | |
9 | 7 | Jean-Philippe Lang | Returns a list of users. |
10 | 7 | Jean-Philippe Lang | |
11 | 7 | Jean-Philippe Lang | +Example+: |
12 | 7 | Jean-Philippe Lang | |
13 | 1 | Jean-Philippe Lang | GET /users.xml |
14 | 1 | Jean-Philippe Lang | |
15 | 10 | Jean-Baptiste Barth | Optional filters: |
16 | 10 | Jean-Baptiste Barth | |
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 | 13 | Go MAEDA | ** @1@: Active (User can login and use their account) |
19 | 13 | Go MAEDA | ** @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 | 13 | Go MAEDA | ** @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 | 10 | Jean-Baptiste Barth | * @group_id@: get only users who are members of the given group |
23 | 10 | Jean-Baptiste Barth | |
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 | 7 | Jean-Philippe Lang | * @password@: the user password |
34 | 7 | Jean-Philippe Lang | * @firstname@ (required) |
35 | 7 | Jean-Philippe Lang | * @lastname@ (required) |
36 | 7 | Jean-Philippe Lang | * @mail@ (required) |
37 | 7 | Jean-Philippe Lang | * @auth_source_id@: authentication mode id |
38 | 12 | Matt Wiseley | * @mail_notification@: only_my_events, none, etc. |
39 | 12 | Matt Wiseley | * @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 | 7 | Jean-Philippe Lang | <user> |
51 | 7 | Jean-Philippe Lang | <login>jplang</login> |
52 | 7 | Jean-Philippe Lang | <firstname>Jean-Philippe</firstname> |
53 | 7 | Jean-Philippe Lang | <lastname>Lang</lastname> |
54 | 7 | Jean-Philippe Lang | <password>secret</password> |
55 | 7 | Jean-Philippe Lang | <mail>jp_lang@yahoo.fr</mail> |
56 | 7 | Jean-Philippe Lang | <auth_source_id>2</auth_source_id> |
57 | 7 | Jean-Philippe Lang | </user> |
58 | 16 | Toshi MARUYAMA | </code></pre> |
59 | 7 | Jean-Philippe Lang | |
60 | 8 | Lutz Horn | JSON |
61 | 8 | Lutz Horn | |
62 | 16 | Toshi MARUYAMA | <pre><code class="json"> |
63 | 8 | Lutz Horn | { |
64 | 8 | Lutz Horn | "user": { |
65 | 8 | Lutz Horn | "login": "jplang", |
66 | 8 | Lutz Horn | "firstname": "Jean-Philippe", |
67 | 8 | Lutz Horn | "lastname": "Lang", |
68 | 8 | Lutz Horn | "mail": "jp_lang@yahoo.fr", |
69 | 8 | Lutz Horn | "password": "secret" |
70 | 8 | Lutz Horn | } |
71 | 8 | Lutz Horn | } |
72 | 16 | Toshi MARUYAMA | </code></pre> |
73 | 8 | Lutz Horn | |
74 | 7 | Jean-Philippe Lang | +Response+: |
75 | 7 | Jean-Philippe Lang | |
76 | 7 | Jean-Philippe Lang | * @201 Created@: user was created |
77 | 7 | Jean-Philippe Lang | * @422 Unprocessable Entity@: user was not created due to validation failures (response body contains the error messages) |
78 | 7 | Jean-Philippe Lang | |
79 | 7 | Jean-Philippe Lang | h2. /users/:id.:format |
80 | 7 | Jean-Philippe Lang | |
81 | 7 | Jean-Philippe Lang | h3. GET |
82 | 7 | Jean-Philippe Lang | |
83 | 7 | Jean-Philippe Lang | Returns the user details. You can use @/users/current.:format@ for retrieving the user whose credentials are used to access the API. |
84 | 7 | Jean-Philippe Lang | |
85 | 3 | Jean-Philippe Lang | +Parameters+: |
86 | 1 | Jean-Philippe Lang | |
87 | 1 | Jean-Philippe Lang | * @include@ (optional): a coma separated list of associations to include in the response: |
88 | 1 | Jean-Philippe Lang | |
89 | 11 | Jean-Baptiste Barth | * @memberships@ : adds extra information about user's memberships and roles on the projects |
90 | 11 | Jean-Baptiste Barth | * @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 | 7 | Jean-Philippe Lang | |
96 | 7 | Jean-Philippe Lang | Returns the details about the current user. |
97 | 7 | Jean-Philippe Lang | |
98 | 1 | Jean-Philippe Lang | GET /users/3.xml?include=memberships,groups |
99 | 1 | Jean-Philippe Lang | |
100 | 1 | Jean-Philippe Lang | Returns the details about user ID 3, and additional detail about the user's project memberships. |
101 | 1 | Jean-Philippe Lang | |
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 | 1 | Jean-Philippe Lang | <id>3</id> |
107 | 1 | Jean-Philippe Lang | <login>jplang</login> |
108 | 1 | Jean-Philippe Lang | <firstname>Jean-Philippe</firstname> |
109 | 1 | Jean-Philippe Lang | <lastname>Lang</lastname> |
110 | 1 | Jean-Philippe Lang | <mail>jp_lang@yahoo.fr</mail> |
111 | 1 | Jean-Philippe Lang | <created_on>2007-09-28T00:16:04+02:00</created_on> |
112 | 1 | Jean-Philippe Lang | <last_login_on>2011-08-01T18:05:45+02:00</last_login_on> |
113 | 14 | Go MAEDA | <api_key>ebc3f6b781a6fb3f2b0a83ce0ebb80e0d585189d</api_key> |
114 | 14 | Go MAEDA | <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 | 4 | Jean-Philippe Lang | <project name="Redmine" id="1"/> |
119 | 4 | Jean-Philippe Lang | <roles type="array"> |
120 | 4 | Jean-Philippe Lang | <role name="Administrator" id="3"/> |
121 | 4 | Jean-Philippe Lang | <role name="Contributor" id="4"/> |
122 | 1 | Jean-Philippe Lang | </roles> |
123 | 1 | Jean-Philippe Lang | </membership> |
124 | 4 | Jean-Philippe Lang | </memberships> |
125 | 4 | Jean-Philippe Lang | <groups type="array"> |
126 | 4 | Jean-Philippe Lang | <group id="20" name="Developers"/> |
127 | 4 | Jean-Philippe Lang | </groups> |
128 | 4 | Jean-Philippe Lang | </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 | 9 | Jean-Baptiste Barth | * @api_key@ : the API key of the user, visible for admins and for yourself (added in 2.3.0) |
133 | 9 | Jean-Baptiste Barth | * @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 | 9 | Jean-Baptiste Barth | |
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 | 1 | Jean-Philippe Lang | |
141 | 7 | Jean-Philippe Lang | PUT /users/20.xml |
142 | 1 | Jean-Philippe Lang | |
143 | 1 | Jean-Philippe Lang | +Parameters+: |
144 | 1 | Jean-Philippe Lang | |
145 | 1 | Jean-Philippe Lang | * @user@ (required): a hash of the user attributes (same as for user creation) |
146 | 1 | Jean-Philippe Lang | |
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 | 1 | Jean-Philippe Lang | +Response+: |
156 | 4 | Jean-Philippe Lang | |
157 | 4 | Jean-Philippe Lang | * @200 OK@: user was deleted |
158 | 7 | Jean-Philippe Lang | |
159 | 7 | Jean-Philippe Lang | h2. See also |
160 | 7 | Jean-Philippe Lang | |
161 | 7 | Jean-Philippe Lang | * The [[Rest_Memberships|Memberships API]] for adding or removing a user from a project. |
162 | 7 | Jean-Philippe Lang | * The [[Rest_Groups|Groups API]] for adding or removing a user from a group. |