Skip to content

Commit a80306e

Browse files
committed
Add docs for POST request
1 parent c1ed205 commit a80306e

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

docs/source/endpoints/users.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,47 @@ The `Location` header contains the URL of the newly created user, and the resour
147147

148148
If no roles have been specified, then a `Member` role is added as a sensible default.
149149

150+
### Create users via CSV
151+
152+
To create a new user from a CSV file, send a `POST` request to the `/@users` endpoint with a `multipart/form-data` body containing a CSV file with the user details.
153+
The endpoint expects the CSV file to be under a "file" part of the `Content-Disposition: multipart/form-data`:
154+
155+
```{eval-rst}
156+
.. http:example:: curl httpie python-requests
157+
:request: ../../../src/plone/restapi/tests/http-examples/users_add_csv_format.req
158+
```
159+
160+
The CSV file's first line is reserved for the header. Possible columns include:
161+
162+
| Column | Type | Example |
163+
|-----------------|--------|---------------------------------|
164+
| `id` (required) | string | jdoe |
165+
| `username` | string | jdoe |
166+
| `fullname` | string | John Doe |
167+
| `description` | string | Software Developer from Berlin. |
168+
| `email` | string | jdoe@example.com |
169+
| `roles` | list | "Member, Contributor" |
170+
| `groups` | list | AuthenticatedUsers |
171+
| `location` | string | Berlin, DE |
172+
| `home_page` | string | jdoe.dev |
173+
| `password` | string | pwd1234 |
174+
175+
```{note}
176+
If you want a user to have more that one role, note that you have to put the roles in quotes (see table above).
177+
```
178+
179+
Example of a minimal CSV file:
180+
181+
```
182+
id,fullname,description,email
183+
jdoe,John Doe,Software Developer from Berlin,jdoe@example.com
184+
```
185+
186+
Response:
187+
188+
```{literalinclude} ../../../src/plone/restapi/tests/http-examples/users_add_csv_format.resp
189+
:language: http
190+
```
150191

151192
## Read User
152193

0 commit comments

Comments
 (0)