Implement todo list RESTful API with Spring boot
- Packaging application by run this command:
mvnw package
- Run application by this command
java -jar target/todoList-0.0.1-SNAPSHOT.jar
Returns json data of all tasks.
-
URL
api/v1/todolist/tasks
-
Method:
GET
-
URL Params
Required:
None
-
Success Response:
-
Code: 200
Content:[ { "id": 1, "subject": "Task1", "content": "Content1", "status": "PENDING", "createdAt": 1517224122769, "updatedAt": 1517224122769 }, { "id": 2, "subject": "Task2", "content": "Content2", "status": "PENDING", "createdAt": 1517224342241, "updatedAt": 1517224342241 } ]
-
-
Sample Call:
GET | http://localhost:8080/api/v1/todolist/tasks
Returns json data about a single task.
-
URL
api/v1/todolist/task/:id
-
Method:
GET
-
URL Params
Required:
id=[integer]
-
Success Response:
-
Code: 200
Content:{ "id": 1, "subject": "Task1", "content": "Content1", "status": "PENDING", "createdAt": 1517224122769, "updatedAt": 1517224122769 }
-
-
Error Response:
- Code: 404 NOT FOUND
Content:null
- Code: 404 NOT FOUND
-
Sample Call:
GET | http://localhost:8080/api/v1/todolist/task/1
Returns json data of a added task.
-
URL
api/v1/todolist/task
-
Method:
POST
-
URL Params
Required:
None
-
Success Response:
-
Code: 200
Content:{ "id": 2, "subject": "Task2", "content": "Content2", "status": "PENDING", "createdAt": 1517224342241, "updatedAt": 1517224342241 }
-
-
Error Response:
- Code: 400 BAD REQUEST
Content:Depend on request
- Code: 400 BAD REQUEST
-
Sample Call:
POST | http://localhost:8080/api/v1/todolist/task Body: { "subject" : "Task2", "content" : "Content2", "status" : "PENDING" }
Returns json data of a edited task.
-
URL
api/v1/todolist/task/:id
-
Method:
PUT
-
URL Params
Required:
id=[integer]
-
Success Response:
-
Code: 200
Content:{ "id": 1, "subject": "Task1 - edited", "content": "Content1 - edited", "status": "DONE", "createdAt": 1517224122769, "updatedAt": 1517224676029 }
-
-
Error Response:
- Code: 400 BAD REQUEST
Content:Depend on request
- Code: 400 BAD REQUEST
-
Sample Call:
PUT | http://localhost:8080/api/v1/todolist/task/1 Body: { "subject" : "Task1 - edited", "content" : "Content1 - edited", "status" : "DONE" }
Returns json data of a edited task.
-
URL
api/v1/todolist/task/:id/status/:status
-
Method:
PUT
-
URL Params
Required:
id=[integer]
status=[String]
-
Success Response:
-
Code: 200
Content:{ "id": 1, "subject": "Task1", "content": "Content1", "status": "DONE", "createdAt": 1517224122769, "updatedAt": 1517224676029 }
-
-
Error Response:
- Code: 500 INTERNAL SERVER ERROR
Content:
{ "timestamp": 1517225176926, "status": 500, "error": "Internal Server Error", "exception": "java.lang.IllegalArgumentException", "message": "No enum constant com.nubbnueng.todoList.model.TaskStatus.DON", "path": "/api/v1/todolist/task/1/status/don" }
- Code: 500 INTERNAL SERVER ERROR
-
Sample Call:
PUT | http://localhost:8080/api/v1/todolist/task/1/status/DONE
-
URL
api/v1/todolist/task/:id
-
Method:
DELETE
-
URL Params
Required:
id=[integer]
-
Success Response:
- Code: 200
Content:null
- Code: 200
-
Error Response:
- Code: 404 NOT FOUND
Content:null
- Code: 404 NOT FOUND
-
Sample Call:
DELETE | http://localhost:8080/api/v1/todolist/task/1