Rest Users » History » Version 8

Lutz Horn, 2013-05-03 12:04
added JSON example for POST /users.xml

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