Rest Users » History » Version 7

Jean-Philippe Lang, 2012-06-03 16:09

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 7 Jean-Philippe Lang
h3. POST
16 1 Jean-Philippe Lang
17 7 Jean-Philippe Lang
Creates a user.
18 1 Jean-Philippe Lang
19 7 Jean-Philippe Lang
+Parameters+:
20 1 Jean-Philippe Lang
21 7 Jean-Philippe Lang
* @user@ (required): a hash of the user attributes, including:
22 1 Jean-Philippe Lang
23 7 Jean-Philippe Lang
  * @login@ (required): the user login
24 7 Jean-Philippe Lang
  * @password@: the user password
25 7 Jean-Philippe Lang
  * @firstname@ (required)
26 7 Jean-Philippe Lang
  * @lastname@ (required)
27 7 Jean-Philippe Lang
  * @mail@ (required)
28 7 Jean-Philippe Lang
  * @auth_source_id@: authentication mode id
29 1 Jean-Philippe Lang
30 7 Jean-Philippe Lang
+Example+:
31 1 Jean-Philippe Lang
32 7 Jean-Philippe Lang
<pre>
33 7 Jean-Philippe Lang
POST /users.xml
34 7 Jean-Philippe Lang
35 7 Jean-Philippe Lang
<?xml version="1.0" encoding="ISO-8859-1" ?>
36 7 Jean-Philippe Lang
<user>
37 7 Jean-Philippe Lang
  <login>jplang</login>
38 7 Jean-Philippe Lang
  <firstname>Jean-Philippe</firstname>
39 7 Jean-Philippe Lang
  <lastname>Lang</lastname>
40 7 Jean-Philippe Lang
  <password>secret</password>
41 7 Jean-Philippe Lang
  <mail>jp_lang@yahoo.fr</mail>
42 7 Jean-Philippe Lang
  <auth_source_id>2</auth_source_id>
43 7 Jean-Philippe Lang
</user>
44 7 Jean-Philippe Lang
</pre>
45 7 Jean-Philippe Lang
46 7 Jean-Philippe Lang
+Response+:
47 7 Jean-Philippe Lang
48 7 Jean-Philippe Lang
  * @201 Created@: user was created
49 7 Jean-Philippe Lang
  * @422 Unprocessable Entity@: user was not created due to validation failures (response body contains the error messages)
50 7 Jean-Philippe Lang
51 7 Jean-Philippe Lang
h2. /users/:id.:format
52 7 Jean-Philippe Lang
53 7 Jean-Philippe Lang
h3. GET
54 7 Jean-Philippe Lang
55 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.
56 7 Jean-Philippe Lang
57 3 Jean-Philippe Lang
+Parameters+:
58 1 Jean-Philippe Lang
59 1 Jean-Philippe Lang
* @include@ (optional): a coma separated list of associations to include in the response:
60 1 Jean-Philippe Lang
61 1 Jean-Philippe Lang
  * @memberships@
62 2 Bevan Rudge
  * @groups@ (added in 2.1)
63 1 Jean-Philippe Lang
64 7 Jean-Philippe Lang
+Examples+:
65 1 Jean-Philippe Lang
66 7 Jean-Philippe Lang
  GET /users/current.xml
67 7 Jean-Philippe Lang
68 7 Jean-Philippe Lang
Returns the details about the current user.
69 7 Jean-Philippe Lang
70 1 Jean-Philippe Lang
  GET /users/3.xml?include=memberships,groups
71 1 Jean-Philippe Lang
72 1 Jean-Philippe Lang
Returns the details about user ID 3, and additional detail about the user's project memberships.
73 1 Jean-Philippe Lang
74 1 Jean-Philippe Lang
+Reponse+:
75 1 Jean-Philippe Lang
76 1 Jean-Philippe Lang
<pre>
77 1 Jean-Philippe Lang
<user>
78 1 Jean-Philippe Lang
  <id>3</id>
79 1 Jean-Philippe Lang
  <login>jplang</login>
80 1 Jean-Philippe Lang
  <firstname>Jean-Philippe</firstname>
81 1 Jean-Philippe Lang
  <lastname>Lang</lastname>
82 1 Jean-Philippe Lang
  <mail>jp_lang@yahoo.fr</mail>
83 1 Jean-Philippe Lang
  <created_on>2007-09-28T00:16:04+02:00</created_on>
84 1 Jean-Philippe Lang
  <last_login_on>2011-08-01T18:05:45+02:00</last_login_on>
85 5 Rick Mason
  <custom_fields type="array" />
86 1 Jean-Philippe Lang
  <memberships type="array">
87 4 Jean-Philippe Lang
    <membership>
88 4 Jean-Philippe Lang
      <project name="Redmine" id="1"/>
89 4 Jean-Philippe Lang
      <roles type="array">
90 4 Jean-Philippe Lang
        <role name="Administrator" id="3"/>
91 4 Jean-Philippe Lang
        <role name="Contributor" id="4"/>
92 1 Jean-Philippe Lang
      </roles>
93 1 Jean-Philippe Lang
    </membership>
94 4 Jean-Philippe Lang
  </memberships>
95 4 Jean-Philippe Lang
  <groups type="array">
96 4 Jean-Philippe Lang
    <group id="20" name="Developers"/>
97 4 Jean-Philippe Lang
  </groups>
98 4 Jean-Philippe Lang
</user>
99 4 Jean-Philippe Lang
</pre>
100 4 Jean-Philippe Lang
101 7 Jean-Philippe Lang
h3. PUT
102 4 Jean-Philippe Lang
103 7 Jean-Philippe Lang
Updates a user.
104 4 Jean-Philippe Lang
105 1 Jean-Philippe Lang
+Example+:
106 1 Jean-Philippe Lang
107 7 Jean-Philippe Lang
  PUT /users/20.xml
108 1 Jean-Philippe Lang
109 1 Jean-Philippe Lang
+Parameters+:
110 1 Jean-Philippe Lang
111 1 Jean-Philippe Lang
* @user@ (required): a hash of the user attributes (same as for user creation)
112 1 Jean-Philippe Lang
113 7 Jean-Philippe Lang
h3. DELETE
114 1 Jean-Philippe Lang
115 7 Jean-Philippe Lang
Deletes a user.
116 4 Jean-Philippe Lang
117 7 Jean-Philippe Lang
+Example+:
118 1 Jean-Philippe Lang
119 7 Jean-Philippe Lang
  DELETE /users/20.xml
120 1 Jean-Philippe Lang
121 1 Jean-Philippe Lang
+Response+:
122 4 Jean-Philippe Lang
123 4 Jean-Philippe Lang
  * @200 OK@: user was deleted
124 7 Jean-Philippe Lang
125 7 Jean-Philippe Lang
h2. See also
126 7 Jean-Philippe Lang
127 7 Jean-Philippe Lang
* The [[Rest_Memberships|Memberships API]] for adding or removing a user from a project.
128 7 Jean-Philippe Lang
* The [[Rest_Groups|Groups API]] for adding or removing a user from a group.