POST favorites/:id
Add a quote in the user's favorites.
- A valid access token must be provided in access_token parameter.
The access_token
should be sent using an HTTP header like so:
Authorization: Bearer access_token
An example call with CURL:
curl --header "Authorization: Bearer ZllAle9NZ11FkMyX5xm0evswWOTinrr5I26uLcGB" --data "" https://api.teen-quotes.com/v1/favorites/42
A JSON object containing keys of the new FavoriteQuote object in the following format:
- id - The ID of the new FavoriteQuote
- quote_id - The ID of the Quote added to the user's favorites
- user_id - The ID of the user currently adding the quote
- created_at - Describes the date when the resource was created
- updated_at - Describes the date when the resource was created
All known errors cause the resource to return HTTP error code header together with a JSON array containing at least status
and error
keys describing the source of error.
- 400 Bad request — When the status key has got one of the following values:
quote_not_found
,quote_already_favorited
.
The error
messages are the following:
- If
status
isquote_not_found
:The quote #:id was not found.
- If
status
isquote_already_favorited
:The quote #:id was already favorited.
- If
status
isquote_not_published
:The quote #:id is not published.
Request
POST https://api.teen-quotes.com/v1/favorites/750
With an HTTP code 201.
{
"user_id":42,
"quote_id":750,
"updated_at":"2014-05-24 14:14:38",
"created_at":"2014-05-24 14:14:38",
"id":2005
}
For an error with HTTP code 400:
{
"status":"quote_already_favorited",
"error":"The quote #750 was already favorited"
}