> ## Documentation Index
> Fetch the complete documentation index at: https://help.dingtalk.io/llms.txt
> Use this file to discover all available pages before exploring further.

# 勤怠レポートからの休暇データの取得

> 勤怠レポートからユーザー ID と休暇名で期間内の休暇列データを取得する API です。

この API を呼び出すと、休暇名とユーザー ID を指定して、DingTalk のスマート勤怠レポートから休暇データを取得します。返されるデータには、指定期間内のレポートの休暇列に含まれるすべての値が含まれます。休暇列は動的に生成されるため、データを取得する際は休暇名を必ず指定してください。

## API 呼び出し説明

その他のデータアクセス・活用機能を利用する場合は、データアセットプラットフォームをご利用ください。データアセットプラットフォーム（dPaaS）は、組織向けの統合データ管理プラットフォームです。DingTalk を基盤として、安全性・拡張性・保守性に優れたデータサービスを提供し、ビジネス上の意思決定を支援します。

## リクエスト

| **基本情報** | |
| - | - |
| HTTP URL | [https://api.dingtalk.io/topapi/attendance/getleavetimebynames](https://api.dingtalk.io/topapi/attendance/getleavetimebynames) |
| HTTP メソッド | POST |
| 対応するアプリタイプ | appType-社内アプリ　appType-サードパーティ社内アプリ |
| 必要な権限 | permission-qyapi\_base-組織 API の呼び出しに必要なベーシック権限 |

### クエリパラメータ

| 名前 | タイプ | 必須 | 例 | 説明 |
| - | - | - | - | - |
| access\_token | String | はい | 6d1bxxxx | この API の呼び出しに使用するアプリ認証情報です。   - 社内アプリの場合は、[社内アプリの access\_token を取得する](https://help.dingtalk.io/ja/open/development/obtain-orgapp-token) API を呼び出して取得します。 - サードパーティ社内アプリの場合は、サードパーティ組織の access\_token を取得する API を呼び出して取得します。 |

### リクエストボディ

| 名前 | タイプ | 必須 | 例 | 説明 |
| - | - | - | - | - |
| userid | String | はい | manager123 | ユーザーのユーザー ID です。 |
| leave\_names | String | はい | 年次有給休暇 | 休暇名です。複数指定する場合はカンマで区切ります。最大長：20。 |
| from\_date | Date | はい | 2020-09-09 12:12:12 | 開始日時です。225 日より前のデータには対応していません。 |
| to\_date | Date | はい | 2020-09-11 12:12:12 | 終了日時です。開始日時と終了日時の間隔は 31 日以内にする必要があります。 |

### リクエスト例

```curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST "https://api.dingtalk.io/topapi/attendance/getleavetimebynames" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=1b8b85xxxxx3ccfdd' \
-d 'from_date=2018-07-11+12%3A12%3A12' \
-d 'leave_names=年次有給休暇' \
-d 'to_date=2018-07-11+12%3A12%3A12' \
-d 'userid=zhangsan'
```

Java

```java theme={"theme":{"light":"github-light","dark":"github-dark"}}
DingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/attendance/getleavetimebynames");
OapiAttendanceGetleavetimebynamesRequest req = new OapiAttendanceGetleavetimebynamesRequest();
req.setUserid("zhangsan");
req.setLeaveNames("年次有給休暇");
req.setFromDate(StringUtils.parseDateTime("2020-09-01 00:00:00"));
req.setToDate(StringUtils.parseDateTime("2020-09-30 00:00:00"));
OapiAttendanceGetleavetimebynamesResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
```

Python

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import dingtalk.api

req=dingtalk.api.OapiAttendanceGetleavetimebynamesRequest("https://api.dingtalk.io/topapi/attendance/getleavetimebynames")

req.userid="zhangsan"
req.leave_names="年次有給休暇"
req.from_date="2018-07-11 12:12:12"
req.to_date="2018-07-11 12:12:12"
try:
  resp= req.getResponse(access_token)
  print(resp)
except Exception,e:
  print(e)
```

PHP

```php theme={"theme":{"light":"github-light","dark":"github-dark"}}
include "TopSdk.php";
date_default_timezone_set('Asia/Shanghai');

$c = new DingTalkClient(DingTalkConstant::$CALL_TYPE_OAPI, DingTalkConstant::$METHOD_POST , DingTalkConstant::$FORMAT_JSON);
$req = new OapiAttendanceGetleavetimebynamesRequest;
$req->setUserid("zhangsan");
$req->setLeaveNames("年次有給休暇");
$req->setFromDate("2018-07-11 12:12:12");
$req->setToDate("2018-07-11 12:12:12");
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/attendance/getleavetimebynames");
```

C#

```csharp theme={"theme":{"light":"github-light","dark":"github-dark"}}
IDingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/attendance/getleavetimebynames");
OapiAttendanceGetleavetimebynamesRequest req = new OapiAttendanceGetleavetimebynamesRequest();
req.Userid = "zhangsan";
req.LeaveNames = "年次有給休暇";
req.FromDate = DateTime.Parse("2018-07-11 12:12:12");
req.ToDate = DateTime.Parse("2018-07-11 12:12:12");
OapiAttendanceGetleavetimebynamesResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
```

## レスポンス

### レスポンスボディ

| 名前 | タイプ | 例 | 説明 |
| - | - | - | - |
| result | ColumnValListForTopVo | | 返却結果です。 |
| columns | ColumnValForTopVo\[] | | 列情報と列値データです。 |
| columnvo | ColumnForTopVo | | 列情報です。 |
| name | String | 私用休暇 | 休暇名です。 |
| sub\_type | Number | 0 | サブタイプです。 |
| status | Number | 0 | 列のステータスです。 |
| alias | String | leave\_ | 表示名です。 |
| type | Number | 0 | 列のタイプです。 |
| columnvals | ColumnDayAndVal\[] | | 列値データです。 |
| value | String | 1.0 | 日ごとの値です。 |
| date | Date | 2020-09-09 12:12:12 | 開始日時です。 |
| errcode | Number | 0 | リターンコードです。 |
| request\_id | String | whv0fhtk8cnc | リクエスト ID です。 |

### レスポンスボディ例

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "errcode": 0,
  "result": {
    "columns": [
      {
        "columnvals": [
          {
            "date": "2020-09-01 00:00:00",
            "value": "0.0"
          },
          {
            "date": "2020-09-02 00:00:00",
            "value": "0.0"                   
          }
        ],
        "columnvo": {
          "alias": "leave_",
          "name": "私用休暇",
          "status": 0,
          "sub_type": 0,
          "type": 0
        }
      }
    ]
  },
  "request_id": "whv0fhtk8cnc"
}
```

### エラーコード

この API の呼び出しでエラーが返された場合は、エラーメッセージをもとに[グローバルエラーコード](https://help.dingtalk.io/ja/open/development/server-api-error-codes-1.md)ドキュメントで解決方法を確認してください。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.