Rest Users » History » Version 15

Go MAEDA, 2017-05-11 08:08
Added send_information parameter

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 7 Jean-Philippe Lang
<pre>
45 7 Jean-Philippe Lang
POST /users.xml
46 7 Jean-Philippe Lang
47 7 Jean-Philippe Lang
<?xml version="1.0" encoding="ISO-8859-1" ?>
48 7 Jean-Philippe Lang
<user>
49 7 Jean-Philippe Lang
  <login>jplang</login>
50 7 Jean-Philippe Lang
  <firstname>Jean-Philippe</firstname>
51 7 Jean-Philippe Lang
  <lastname>Lang</lastname>
52 7 Jean-Philippe Lang
  <password>secret</password>
53 7 Jean-Philippe Lang
  <mail>jp_lang@yahoo.fr</mail>
54 7 Jean-Philippe Lang
  <auth_source_id>2</auth_source_id>
55 7 Jean-Philippe Lang
</user>
56 7 Jean-Philippe Lang
</pre>
57 7 Jean-Philippe Lang
58 8 Lutz Horn
JSON
59 8 Lutz Horn
60 8 Lutz Horn
<pre>
61 8 Lutz Horn
{
62 8 Lutz Horn
    "user": {
63 8 Lutz Horn
        "login": "jplang",
64 8 Lutz Horn
        "firstname": "Jean-Philippe",
65 8 Lutz Horn
        "lastname": "Lang",
66 8 Lutz Horn
        "mail": "jp_lang@yahoo.fr",
67 8 Lutz Horn
        "password": "secret"
68 8 Lutz Horn
    }
69 8 Lutz Horn
}
70 8 Lutz Horn
</pre>
71 8 Lutz Horn
72 7 Jean-Philippe Lang
+Response+:
73 7 Jean-Philippe Lang
74 7 Jean-Philippe Lang
  * @201 Created@: user was created
75 7 Jean-Philippe Lang
  * @422 Unprocessable Entity@: user was not created due to validation failures (response body contains the error messages)
76 7 Jean-Philippe Lang
77 7 Jean-Philippe Lang
h2. /users/:id.:format
78 7 Jean-Philippe Lang
79 7 Jean-Philippe Lang
h3. GET
80 7 Jean-Philippe Lang
81 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.
82 7 Jean-Philippe Lang
83 3 Jean-Philippe Lang
+Parameters+:
84 1 Jean-Philippe Lang
85 1 Jean-Philippe Lang
* @include@ (optional): a coma separated list of associations to include in the response:
86 1 Jean-Philippe Lang
87 11 Jean-Baptiste Barth
  * @memberships@ : adds extra information about user's memberships and roles on the projects
88 11 Jean-Baptiste Barth
  * @groups@ (added in 2.1) : adds extra information about user's groups
89 1 Jean-Philippe Lang
90 7 Jean-Philippe Lang
+Examples+:
91 1 Jean-Philippe Lang
92 7 Jean-Philippe Lang
  GET /users/current.xml
93 7 Jean-Philippe Lang
94 7 Jean-Philippe Lang
Returns the details about the current user.
95 7 Jean-Philippe Lang
96 1 Jean-Philippe Lang
  GET /users/3.xml?include=memberships,groups
97 1 Jean-Philippe Lang
98 1 Jean-Philippe Lang
Returns the details about user ID 3, and additional detail about the user's project memberships.
99 1 Jean-Philippe Lang
100 1 Jean-Philippe Lang
+Reponse+:
101 1 Jean-Philippe Lang
102 1 Jean-Philippe Lang
<pre>
103 1 Jean-Philippe Lang
<user>
104 1 Jean-Philippe Lang
  <id>3</id>
105 1 Jean-Philippe Lang
  <login>jplang</login>
106 1 Jean-Philippe Lang
  <firstname>Jean-Philippe</firstname>
107 1 Jean-Philippe Lang
  <lastname>Lang</lastname>
108 1 Jean-Philippe Lang
  <mail>jp_lang@yahoo.fr</mail>
109 1 Jean-Philippe Lang
  <created_on>2007-09-28T00:16:04+02:00</created_on>
110 1 Jean-Philippe Lang
  <last_login_on>2011-08-01T18:05:45+02:00</last_login_on>
111 14 Go MAEDA
  <api_key>ebc3f6b781a6fb3f2b0a83ce0ebb80e0d585189d</api_key>
112 14 Go MAEDA
  <status>1</status>
113 5 Rick Mason
  <custom_fields type="array" />
114 1 Jean-Philippe Lang
  <memberships type="array">
115 4 Jean-Philippe Lang
    <membership>
116 4 Jean-Philippe Lang
      <project name="Redmine" id="1"/>
117 4 Jean-Philippe Lang
      <roles type="array">
118 4 Jean-Philippe Lang
        <role name="Administrator" id="3"/>
119 4 Jean-Philippe Lang
        <role name="Contributor" id="4"/>
120 1 Jean-Philippe Lang
      </roles>
121 1 Jean-Philippe Lang
    </membership>
122 4 Jean-Philippe Lang
  </memberships>
123 4 Jean-Philippe Lang
  <groups type="array">
124 4 Jean-Philippe Lang
    <group id="20" name="Developers"/>
125 4 Jean-Philippe Lang
  </groups>
126 4 Jean-Philippe Lang
</user>
127 4 Jean-Philippe Lang
</pre>
128 4 Jean-Philippe Lang
129 9 Jean-Baptiste Barth
Depending on the status of the user who makes the request, you can get some more details:
130 9 Jean-Baptiste Barth
* @api_key@ : the API key of the user, visible for admins and for yourself (added in 2.3.0)
131 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.
132 9 Jean-Baptiste Barth
133 7 Jean-Philippe Lang
h3. PUT
134 4 Jean-Philippe Lang
135 7 Jean-Philippe Lang
Updates a user.
136 4 Jean-Philippe Lang
137 1 Jean-Philippe Lang
+Example+:
138 1 Jean-Philippe Lang
139 7 Jean-Philippe Lang
  PUT /users/20.xml
140 1 Jean-Philippe Lang
141 1 Jean-Philippe Lang
+Parameters+:
142 1 Jean-Philippe Lang
143 1 Jean-Philippe Lang
* @user@ (required): a hash of the user attributes (same as for user creation)
144 1 Jean-Philippe Lang
145 7 Jean-Philippe Lang
h3. DELETE
146 1 Jean-Philippe Lang
147 7 Jean-Philippe Lang
Deletes a user.
148 4 Jean-Philippe Lang
149 7 Jean-Philippe Lang
+Example+:
150 1 Jean-Philippe Lang
151 7 Jean-Philippe Lang
  DELETE /users/20.xml
152 1 Jean-Philippe Lang
153 1 Jean-Philippe Lang
+Response+:
154 4 Jean-Philippe Lang
155 4 Jean-Philippe Lang
  * @200 OK@: user was deleted
156 7 Jean-Philippe Lang
157 7 Jean-Philippe Lang
h2. See also
158 7 Jean-Philippe Lang
159 7 Jean-Philippe Lang
* The [[Rest_Memberships|Memberships API]] for adding or removing a user from a project.
160 7 Jean-Philippe Lang
* The [[Rest_Groups|Groups API]] for adding or removing a user from a group.