@zhongjianxin
2018-12-04T22:07:47.000000Z
字数 1489
阅读 1096
OOCL
java -jar todo-list-rest-api-0.1.0.jar
Resource Structure Example:
{
"id": 1, // auto generate by server
"content": "Remove unused imports",
"status": "active"
}
**注意:** status="active"/"completed"
Call API Example:
GET: http://localhost:8080/api/todos
Note :After you get the the response from Todo-API Get, you will see todo array is a property of this response. you need to get it first, so that can use it as a array. a response example as below:
{
"_embedded" : {
"todos" : [ {
"id" : 1,
"content" : "Remove unused imports",
"status" : "active",
"_links" : {
"self" : {
"href" : "http://localhost:8080/api/todos/1"
},
"todo" : {
"href" : "http://localhost:8080/api/todos/1"
}
}
}, {
"id" : 2,
"content" : "Clean the code",
"status" : "completed",
"_links" : {
"self" : {
"href" : "http://localhost:8080/api/todos/2"
},
"todo" : {
"href" : "http://localhost:8080/api/todos/2"
}
}
}
}
POST: http://localhost:8080/api/todos
GET ALL: http://localhost:8080/api/todos/search/statusOfTodos?status=completed,active
GET active: http://localhost:8080/api/todos/search/statusOfTodos?status=active
GET completed: http://localhost:8080/api/todos/search/statusOfTodos?status=completed
PATCH http://localhost:8080/api/todos/5
body:
{
"status" : "completed"
}
PATCH http://localhost:8080/api/todos/5
body:
{
"content" : "updated new content"
}