---
# System prepended metadata

title: Backend_Training v2

---

---
title: Backend_Training v2
---

**新增 Todo**
----
  新增一條 Todo 項目

* **URL**

  /todo

* **Method:**
  

  `POST`
  
*  **URL Params**

   None

* **Data Params**

  ```code
  {
    "id": "uuidv4",
    "text": "todo context",
    "isCompleted": false
  }
  ```

* **Success Response:**

  * **Code:** 201 <br />
    **Content:** `{ "message" : "added a todo item successfully" }`
 
* **Error Response:**

  * **Code:** 422 UNPROCESSABLE <br />
<!--     **Content:** `{ error : "Log in" }` -->

* **Sample Call:**

  ```javascript
    $.ajax({
      url: "/todo",
      dataType: "json",
      type : "POST",
      success : function(r) {
        console.log(r);
      }
    });
  ```
  
**取得 Todo 列表**
----
  取得 Todo 列表

* **URL**

  /todo

* **Method:**
  

  `GET`
  
*  **URL Params**

   None

* **Data Params**

  None

* **Success Response:**

  * **Code:** 200 <br />
    **Content:** 
    ```json
    [
        {
            "id": "3d8d9738-cd9f-4e3f-aa61-6b93ba1913c5",
            "text": "asdafs",
            "isCompleted": false,
            "completeTime": null
        }
    ]
    ```
 
* **Error Response:**

  * **Code:** 422 UNPROCESSABLE <br />
<!--     **Content:** `{ error : "Log in" }` -->

* **Sample Call:**

  ```javascript
    $.ajax({
      url: "/todo",
      dataType: "json",
      type : "GET",
      success : function(r) {
        console.log(r);
      }
    });
  ```
  
**標記 Todo 完成**
----
  標記 Todo 完成

* **URL**

  /todo

* **Method:**
  

  `PUT`
  
* **URL Params**

  None

* **Data Params**

    ```json
    [
        {
            "id": "3d8d9738-cd9f-4e3f-aa61-6b93ba1913c5",
            "text": "asdafs",
            "isCompleted": true,
            "completeTime": "完成時間：2000 / 12 / 31 23 : 59"
        }
    ]
    ```

* **Success Response:**

  * **Code:** 204 <br />
    **Content:** `{ "message" : "mark complete successfully" }`
 
* **Error Response:**

  * **Code:** 422 UNPROCESSABLE <br />
<!--     **Content:** `{ error : "Log in" }` -->

* **Sample Call:**

  ```javascript
    $.ajax({
      url: "/todo",
      dataType: "json",
      type : "PUT",
      success : function(r) {
        console.log(r);
      }
    });
  ```
  
**刪除 Todo 項目**
----
  刪除一個 Todo 項目

* **URL**

  /todo/:id

* **Method:**
  
  `DELETE`
  
* **URL Params**

  `id: uuidv4`

* **Data Params**

    Node

* **Success Response:**

  * **Code:** 204 <br />
    **Content:** `{ "message" : "deleted a todo item successfully" }`
 
* **Error Response:**

  * **Code:** 422 UNPROCESSABLE <br />
<!--     **Content:** `{ error : "Log in" }` -->

* **Sample Call:**

  ```javascript
    $.ajax({
      url: "/todo/3d8d9738-cd9f-4e3f-aa61-6b93ba1913c5",
      dataType: "json",
      type : "DELETE",
      success : function(r) {
        console.log(r);
      }
    });
  ```
  
**使用 Excel 上傳 Todo 項目**
----
  使用 Excel 上傳 Todo 項目

* **URL**

  /todo/upload

* **Method:**
  
  `POST`
  
* **URL Params**

  None

* **Data Params**

  ```json
      'file': 'selected file'
  ```

* **Success Response:**

  * **Code:** 201 <br />
 
* **Error Response:**

  * **Code:** 422 UNPROCESSABLE <br />
<!--     **Content:** `{ error : "Log in" }` -->

* **Sample Call:**

  ```javascript
    $.ajax({
      url: "/todo/upload",
      dataType: "json",
      type : "POST",
      success : function(r) {
        console.log(r);
      }
    });
  ```
  
**下載 Todolist Excel 檔案**
----
  下載 Todolist Excel 檔案

* **URL**

  /todo/download

* **Method:**
  
  `GET`
  
* **URL Params**

  None

* **Data Params**

  None

* **Success Response:**

  * **Code:** 200 <br />
 
* **Error Response:**

  * **Code:** 422 UNPROCESSABLE <br />
<!--     **Content:** `{ error : "Log in" }` -->

* **Sample Call:**

  ```javascript
    $.ajax({
      url: "/todo/download",
      dataType: "json",
      type : "GET",
      success : function(r) {
        console.log(r);
      }
    });
  ```