> ## 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.

# 休暇時間の計算

> 社員の userId と開始・終了時刻を指定し、シフト設定のルールに基づいた休暇時間を分単位で取得する API です。

この API を呼び出すと、シフト設定のルールに基づいて自動計算された各社員の休暇時間を取得できます。

## リクエスト

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

### クエリパラメータ

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

### リクエストボディ

| 名前 | タイプ | 必須 | 例 | 説明 |
| - | - | - | - | - |
| userid | String | はい | user123 | 社内における社員のユーザー ID です。組織はこのフィールドでユーザーを一意に識別します。 |
| from\_date | Date | はい | 2016-03-09 11:11:11 | 休暇の開始日時です。 |
| to\_date | Date | はい | 2016-03-10 11:11:11 | 休暇の終了日時です。 |

### リクエスト例

```curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST "https://api.dingtalk.io/topapi/attendance/getleaveapproveduration" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=6777xxxx6f4eff' \
-d 'from_date=2016-03-09+11%3A11%3A11' \
-d 'to_date=2016-03-10+11%3A11%3A11' \
-d 'userid=zhangsan'
```

Java

```java theme={"theme":{"light":"github-light","dark":"github-dark"}}
DingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/attendance/getleaveapproveduration");
OapiAttendanceGetleaveapprovedurationRequest req = new OapiAttendanceGetleaveapprovedurationRequest();
req.setUserid("user123");
req.setFromDate(StringUtils.parseDateTime("2016-03-09 11:11:11"));
req.setToDate(StringUtils.parseDateTime("2016-03-10 11:11:11"));
OapiAttendanceGetleaveapprovedurationResponse 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.OapiAttendanceGetleaveapprovedurationRequest("https://api.dingtalk.io/topapi/attendance/getleaveapproveduration")

req.userid="zhangsan"
req.from_date="2016-03-09 11:11:11"
req.to_date="2016-03-10 11:11:11"
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 OapiAttendanceGetleaveapprovedurationRequest;
$req->setUserid("zhangsan");
$req->setFromDate("2016-03-09 11:11:11");
$req->setToDate("2016-03-10 11:11:11");
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/attendance/getleaveapproveduration");
```

C#

```csharp theme={"theme":{"light":"github-light","dark":"github-dark"}}
IDingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/attendance/getleaveapproveduration");
OapiAttendanceGetleaveapprovedurationRequest req = new OapiAttendanceGetleaveapprovedurationRequest();
req.Userid = "zhangsan";
req.FromDate = DateTime.Parse("2016-03-09 11:11:11");
req.ToDate = DateTime.Parse("2016-03-10 11:11:11");
OapiAttendanceGetleaveapprovedurationResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
```

## レスポンス

### レスポンスボディ

| 名前 | タイプ | 例 | 説明 |
| - | - | - | - |
| result | ApproveDurationForTopVo | | 返却結果です。 |
| duration\_in\_minutes | Number | 0 | 休暇時間（分単位）です。 |
| errcode | Number | 0 | 戻りコードです。 |
| errmsg | String | ok | 戻りコードの説明です。 |
| request\_id | String | 3ynh2gp5ndke | リクエスト ID です。 |

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

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "errcode": 0,
  "errmsg":"ok",
  "result": {
    "duration_in_minutes": 480
  },
  "request_id": "6porp1hqkb9k"
}
```

### エラーコード

この 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.