[关闭]
@zhongjianxin 2018-12-04T22:07:47.000000Z 字数 1489 阅读 1096

OOCL-Todo List Backend API Server

OOCL


Java Based API Server:

  1. java -jar todo-list-rest-api-0.1.0.jar

Rest API Method Calling Example

Resource Structure Example:

  1. {
  2. "id": 1, // auto generate by server
  3. "content": "Remove unused imports",
  4. "status": "active"
  5. }
  6. **注意:** status="active"/"completed"

Call API Example:

  1. 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:

  1. {
  2. "_embedded" : {
  3. "todos" : [ {
  4. "id" : 1,
  5. "content" : "Remove unused imports",
  6. "status" : "active",
  7. "_links" : {
  8. "self" : {
  9. "href" : "http://localhost:8080/api/todos/1"
  10. },
  11. "todo" : {
  12. "href" : "http://localhost:8080/api/todos/1"
  13. }
  14. }
  15. }, {
  16. "id" : 2,
  17. "content" : "Clean the code",
  18. "status" : "completed",
  19. "_links" : {
  20. "self" : {
  21. "href" : "http://localhost:8080/api/todos/2"
  22. },
  23. "todo" : {
  24. "href" : "http://localhost:8080/api/todos/2"
  25. }
  26. }
  27. }
  28. }
  1. POST: http://localhost:8080/api/todos
  1. GET ALL: http://localhost:8080/api/todos/search/statusOfTodos?status=completed,active
  1. GET active: http://localhost:8080/api/todos/search/statusOfTodos?status=active
  1. GET completed: http://localhost:8080/api/todos/search/statusOfTodos?status=completed
  1. PATCH http://localhost:8080/api/todos/5
  2. body:
  3. {
  4. "status" : "completed"
  5. }
  1. PATCH http://localhost:8080/api/todos/5
  2. body:
  3. {
  4. "content" : "updated new content"
  5. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注