library-rpc
Create a new book.
RPC
books.createCreates a book in "available" status and links it to its author. The server assigns the "id", "createdAt" and "updatedAt" fields.
Servers
•
mock: https://mock.api.selfdochub.com/rpcParameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| title | params | string | yes | The book's display title, 1-200 characters. |
| isbn | params | string | yes | The book's ISBN. Must be unique across the catalog. |
| authorId | params | string | yes | The id of an existing Author who wrote this book. |
| publishedYear | params | integer | yes | The year the book was first published. Must be between 1450 and next year. |
Responses
result The book that was created.
application/json
| Field | Type | Required | Description |
|---|---|---|---|
| authorId | string | yes | The id of the Author who wrote this book. |
| createdAt | string (date-time) | yes | When the book record was created. |
| id | string | yes | Unique identifier assigned by the server, prefixed with bk_. |
| isbn | string | yes | The book's ISBN. Must be unique across the catalog. |
| publishedYear | integer | yes | The year the book was first published. Must be between 1450 and next year. |
| status | string | yes | A book's availability. "borrowed" means it is out on an open loan. Allowed values: available, borrowed |
| title | string | yes | The book's display title, 1-200 characters. |
| updatedAt | string (date-time) | yes | When the book record was last modified. |
Errors
| Code | Message | Description |
|---|---|---|
| -32602 | Invalid params | |
| -32004 | Not found | |
| -32001 | Conflict |
Request example
{
"id": 1,
"jsonrpc": "2.0",
"method": "books.create",
"params": {
"authorId": "authorId_2",
"isbn": "isbn_704",
"publishedYear": 106,
"title": "title_403"
}
}Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"authorId": "authorId_722",
"createdAt": "createdAt_391",
"id": "id_431",
"isbn": "isbn_255",
"publishedYear": 84,
"status": "borrowed",
"title": "title_355",
"updatedAt": "updatedAt_971"
}
}