Create a Preference
This endpoint creates a user preference
info
This operation requires that the user authenticated is the same as {id}
or that the user has the admin role.
HTTP Request
POST /api/v2/user/{id}/preference/
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
id | path | string | true | A unique integer value identifying the current user id (can also be used 'me' to identify the user currently authenticated) |
body | body | User Preferences | true | The request body should be a json with two parameters: key and value |
Example Body Parameters
- JSON
{
"key": "string",
"value": "json"
}
Example Request
- JavaScript
- Bash
const inputBody = '{
"key": "string",
"value": "json"
}';
const headers = {
'Content-Type':'application/x-www-form-urlencoded',
'Accept':'application/json',
'Authorization': 'Bearer {access_token}'
};
fetch('/api/v2/user/1/preference/',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
# You can also use wget
curl -X POST /api/v2/user/1/preference/ \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer {access_token}' \
--DATA '{body}'
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
201 | Created | Response status code | User Preferences |
Example responses
- 201
{
"id": "integer",
"user_id": "integer",
"key": "string",
"value": "json",
"created_at": "string",
"last_updated_at": "string"
}