---
# System prepended metadata

title: 匯入個案名單API

---

# 匯入個案名單API
[TOC]

## 匯入個案名單

```url=
POST /company/case/import
```

匯入資料格式:
[參見HV-675的附檔](https://nssi2.atlassian.net/jira/software/projects/HV/boards/48?assignee=5e391744b341530e62acf2b0&selectedIssue=HV-675)

**Request**
* body format: form-data

|  欄位 | 型態  | 必填 | 預設 | 說明  |
|---|---|---|---|---|
| file | File | Y | | 匯入的excel檔案 |

![](https://i.imgur.com/StwpHia.png)


**Response**

|  欄位 | 型態   | 說明  |
| -----| -----|-------- |
| totalCount | int | 匯入處理筆數 |
| successCount | int | 匯入成功筆數 |
| failCount | int | 匯入失敗筆數 |
| failuresId | string | 匯入失敗檔案下載id | 

* HTTP 200
```javascript
//匯入成功
{
    "httpCode": 200,
    "result": {
        "data": {
            "totalCount": 30,
            "successCount": 30,
            "failCount": 0,
            "failuresId": null
        }
    }
}

//匯入失敗
{
    "httpCode": 200,
    "result": {
        "data": {
            "totalCount": 30,
            "successCount": 0,
            "failCount": 30,
            "failuresId": "18982a76-7062-44cd-a27e-d132da550b52"
        }
    }
}
```

* HTTP 400
```javascript
// 未選擇上傳檔案
{
    "errorMsg": "API_ERROR.ARGUMENT_ERROR",
    "httpCode": 400
}

//匯入檔案非excel 格式
{
    "errorMsg": "API_ERROR.IMPORT_FILE_FORMAT_ERROR",
    "httpCode": 400
}

// 未選擇上傳檔案 或 未知錯誤
{
    "errorMsg": "API_ERROR.SYSTEM_ERROR",
    "httpCode": 400
}
```


## 下載錯誤資料檔

```url=
POST /company/case/export-failures
```

**Request**

|  欄位 | 型態  | 必填 | 預設 | 說明  |
|---|---|---|---|---|
| failuresId | string | | 匯入失敗檔案下載id | 

```javascript
{
    "failuresId": "18982a76-7062-44cd-a27e-d132da550b52"
}
```

**Response**

* httpCode 400 - [errorMsg](https://gitlab.devpack.cc/Wei_Chang/wicc-kmuh/wikis/Type-Definition#service_error) 

| errorMsg |   desc   |
| --------- |-------- |
|NOT_EXIST|  資料檔不存在 |


* httpCode 200 -Download file

```
File name: [failuresId].xlsx 
```
