Users
The Users resource is used to create and list users.
Listing users
A GET request will list all of the service’s users.
Response structure
| Path | Type | Description |
|---|---|---|
|
|
An array of User resources |
|
|
Links to other resources |
|
|
The pagination information |
Example request
$ curl 'http://localhost:8080/api/users' -i -X GET
Example response
HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/hal+json
Content-Length: 1477
{
"_embedded" : {
"chatty:users" : [ {
"id" : "user_1",
"fullName" : "Kai Toedter",
"email" : "kai@toedter.com",
"_links" : {
"self" : {
"href" : "http://localhost:8080/api/users/user_1"
},
"chatty:user" : {
"href" : "http://localhost:8080/api/users/user_1{?projection}",
"templated" : true
},
"chatty:messages" : {
"href" : "http://localhost:8080/api/users/user_1/messages{?projection}",
"templated" : true
}
}
}, {
"id" : "user_2",
"fullName" : "John Doe",
"email" : "john@doe.com",
"_links" : {
"self" : {
"href" : "http://localhost:8080/api/users/user_2"
},
"chatty:user" : {
"href" : "http://localhost:8080/api/users/user_2{?projection}",
"templated" : true
},
"chatty:messages" : {
"href" : "http://localhost:8080/api/users/user_2/messages{?projection}",
"templated" : true
}
}
} ]
},
"_links" : {
"self" : {
"href" : "http://localhost:8080/api/users"
},
"profile" : {
"href" : "http://localhost:8080/api/profile/users"
},
"curies" : [ {
"href" : "http://localhost:8080/../docs/html5/{rel}.html",
"name" : "chatty",
"templated" : true
} ]
},
"page" : {
"size" : 20,
"totalElements" : 2,
"totalPages" : 1,
"number" : 0
}
}
Links
| Relation | Description |
|---|---|
|
The Users resource |
|
The profile describes the data structure of this resource |
|
Curies are used for online documentation |
Creating a user
A POST request is used to create a user
Request structure
| Path | Type | Description |
|---|---|---|
|
|
The id of the user. Must be unique. |
|
|
The full name of the user |
|
|
The e-mail of the user |
Example request
$ curl 'http://localhost:8080/api/users' -i -X POST \
-H 'Content-Type: application/hal+json' \
-d '{
"fullName" : "toedter_k",
"id" : "toedter_k",
"email" : "kai@toedter.com"
}'
Example response
HTTP/1.1 201 Created
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Location: http://localhost:8080/api/users/toedter_k
User
The User resource is used to get and change a single user.
Getting a user
Response structure
| Path | Type | Description |
|---|---|---|
|
|
The id of the user. Must be unique. |
|
|
The full name of the user |
|
|
The e-mail of the user |
|
|
Links to other resources |
Example request
$ curl 'http://localhost:8080/api/users/user_1' -i -X GET
Example response
HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/hal+json
Content-Length: 577
{
"id" : "user_1",
"fullName" : "John Doe",
"email" : "john@doe.com",
"_links" : {
"self" : {
"href" : "http://localhost:8080/api/users/user_1"
},
"chatty:user" : {
"href" : "http://localhost:8080/api/users/user_1{?projection}",
"templated" : true
},
"chatty:messages" : {
"href" : "http://localhost:8080/api/users/user_1/messages{?projection}",
"templated" : true
},
"curies" : [ {
"href" : "http://localhost:8080/../docs/html5/{rel}.html",
"name" : "chatty",
"templated" : true
} ]
}
}
Links
| Relation | Description |
|---|---|
|
the self link to this user |
|
the (possibly templated) link to this user |
|
The Messages of this user |
|
Curies are used for online documentation |