Request
Basic Information
| Field | Value |
|---|---|
| HTTP URL | https://api.dingtalk.io/v1.0/attendance/vacations/records/query |
| HTTP Method | POST |
| Supported app types | appType-Internal app appType-Third-party enterprise app |
| Permissions | permission-qyapi_holiday_readonly-DingTalk leave query permission |
Request Header
| Name | Type | Required | Description |
|---|---|---|---|
| x-acs-dingtalk-access-token | String | Yes | The access credential for calling this API. Get it as follows: - Internal app: Call the Get the access token of an internal app API. - Third-party enterprise app: Call the API to get the access token of an organization that has authorized the third-party app. |
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| opUserId | String | Yes | The userId of an admin in your organization who has the OA Approval app permissions. Pass the userId of the Super Admin. Call the Get the admin list API and use the userId field of the Super Admin in the response. |
| leaveCode | String | Yes | The unique identifier of the leave type. Call the Query the leave rules list API to get the leave_code value. |
| userIds | Array of String | Yes | The list of userIds of the employees to query. Pass up to 50 userIds per call. |
| pageNumber | Long | Yes | The pagination cursor: - For the first query, pass 0. - For subsequent queries, pass the cumulative offset from the previous query. |
| pageSize | Integer | Yes | The pagination offset. Maximum: 200. |
Request Example
HTTPPOST /v1.0/attendance/vacations/records/query HTTP/1.1
Host:api.dingtalk.io
x-acs-dingtalk-access-token:xxxxx
Content-Type:application/json
{
"opUserId" : "user01",
"leaveCode" : "f84a2dxxxx",
"userIds" : [ "user1" ],
"pageNumber" : 1,
"pageSize" : 100
}
// This file is auto-generated, don't edit it. Thanks.
package com.aliyun.sample;
import com.aliyun.tea.*;
public class Sample {
/**
* Initialize the account Client with a Token
* @return Client
* @throws Exception
*/
public static com.aliyun.dingtalkattendance_1_0.Client createClient() throws Exception {
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
config.protocol = "https";
config.regionId = "central";
return new com.aliyun.dingtalkattendance_1_0.Client(config);
}
public static void main(String[] args_) throws Exception {
java.util.List<String> args = java.util.Arrays.asList(args_);
com.aliyun.dingtalkattendance_1_0.Client client = Sample.createClient();
com.aliyun.dingtalkattendance_1_0.models.GetLeaveRecordsHeaders getLeaveRecordsHeaders = new com.aliyun.dingtalkattendance_1_0.models.GetLeaveRecordsHeaders();
getLeaveRecordsHeaders.xAcsDingtalkAccessToken = "<your access token>";
com.aliyun.dingtalkattendance_1_0.models.GetLeaveRecordsRequest getLeaveRecordsRequest = new com.aliyun.dingtalkattendance_1_0.models.GetLeaveRecordsRequest()
.setOpUserId("user01")
.setLeaveCode("f84a2dxxxx")
.setUserIds(java.util.Arrays.asList(
"user1"
))
.setPageNumber(1L)
.setPageSize(100);
try {
client.getLeaveRecordsWithOptions(getLeaveRecordsRequest, getLeaveRecordsHeaders, new com.aliyun.teautil.models.RuntimeOptions());
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err contains the code and message attributes to help developers locate the issue
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err contains the code and message attributes to help developers locate the issue
}
}
}
}
# -*- coding: utf-8 -*-
# This file is auto-generated, don't edit it. Thanks.
import sys
from typing import List
from alibabacloud_dingtalk.attendance_1_0.client import Client as dingtalkattendance_1_0Client
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_dingtalk.attendance_1_0 import models as dingtalkattendance__1__0_models
from alibabacloud_tea_util import models as util_models
from alibabacloud_tea_util.client import Client as UtilClient
class Sample:
def __init__(self):
pass
@staticmethod
def create_client() -> dingtalkattendance_1_0Client:
"""
Initialize the account Client with a Token
@return: Client
@throws Exception
"""
config = open_api_models.Config()
config.protocol = 'https'
config.region_id = 'central'
return dingtalkattendance_1_0Client(config)
@staticmethod
def main(
args: List[str],
) -> None:
client = Sample.create_client()
get_leave_records_headers = dingtalkattendance__1__0_models.GetLeaveRecordsHeaders()
get_leave_records_headers.x_acs_dingtalk_access_token = '<your access token>'
get_leave_records_request = dingtalkattendance__1__0_models.GetLeaveRecordsRequest(
op_user_id='user01',
leave_code='f84a2dxxxx',
user_ids=[
'user1'
],
page_number=1,
page_size=100
)
try:
client.get_leave_records_with_options(get_leave_records_request, get_leave_records_headers, util_models.RuntimeOptions())
except Exception as err:
if not UtilClient.empty(err.code) and not UtilClient.empty(err.message):
# err contains the code and message attributes to help developers locate the issue
pass
@staticmethod
async def main_async(
args: List[str],
) -> None:
client = Sample.create_client()
get_leave_records_headers = dingtalkattendance__1__0_models.GetLeaveRecordsHeaders()
get_leave_records_headers.x_acs_dingtalk_access_token = '<your access token>'
get_leave_records_request = dingtalkattendance__1__0_models.GetLeaveRecordsRequest(
op_user_id='user01',
leave_code='f84a2dxxxx',
user_ids=[
'user1'
],
page_number=1,
page_size=100
)
try:
await client.get_leave_records_with_options_async(get_leave_records_request, get_leave_records_headers, util_models.RuntimeOptions())
except Exception as err:
if not UtilClient.empty(err.code) and not UtilClient.empty(err.message):
# err contains the code and message attributes to help developers locate the issue
pass
if __name__ == '__main__':
Sample.main(sys.argv[1:])
<?php
// This file is auto-generated, don't edit it. Thanks.
namespace AlibabaCloud\SDK\Sample;
use AlibabaCloud\SDK\Dingtalk\Vattendance_1_0\Dingtalk;
use \Exception;
use AlibabaCloud\Tea\Exception\TeaError;
use AlibabaCloud\Tea\Utils\Utils;
use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\SDK\Dingtalk\Vattendance_1_0\Models\GetLeaveRecordsHeaders;
use AlibabaCloud\SDK\Dingtalk\Vattendance_1_0\Models\GetLeaveRecordsRequest;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
class Sample {
/**
* Initialize the account Client with a Token
* @return Dingtalk Client
*/
public static function createClient(){
$config = new Config([]);
$config->protocol = "https";
$config->regionId = "central";
return new Dingtalk($config);
}
/**
* @param string[] $args
* @return void
*/
public static function main($args){
$client = self::createClient();
$getLeaveRecordsHeaders = new GetLeaveRecordsHeaders([]);
$getLeaveRecordsHeaders->xAcsDingtalkAccessToken = "<your access token>";
$getLeaveRecordsRequest = new GetLeaveRecordsRequest([
"opUserId" => "user01",
"leaveCode" => "f84a2dxxxx",
"userIds" => [
"user1"
],
"pageNumber" => 1,
"pageSize" => 100
]);
try {
$client->getLeaveRecordsWithOptions($getLeaveRecordsRequest, $getLeaveRecordsHeaders, new RuntimeOptions([]));
}
catch (Exception $err) {
if (!($err instanceof TeaError)) {
$err = new TeaError([], $err->getMessage(), $err->getCode(), $err);
}
if (!Utils::empty_($err->code) && !Utils::empty_($err->message)) {
// err contains the code and message attributes to help developers locate the issue
}
}
}
}
$path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
if (file_exists($path)) {
require_once $path;
}
Sample::main(array_slice($argv, 1));
// This file is auto-generated, don't edit it. Thanks.
package main
import (
"os"
util "github.com/alibabacloud-go/tea-utils/v2/service"
dingtalkattendance_1_0 "github.com/alibabacloud-go/dingtalk/attendance_1_0"
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
"github.com/alibabacloud-go/tea/tea"
)
/**
* Initialize the account Client with a Token
* @return Client
* @throws Exception
*/
func CreateClient () (_result *dingtalkattendance_1_0.Client, _err error) {
config := &openapi.Config{}
config.Protocol = tea.String("https")
config.RegionId = tea.String("central")
_result = &dingtalkattendance_1_0.Client{}
_result, _err = dingtalkattendance_1_0.NewClient(config)
return _result, _err
}
func _main (args []*string) (_err error) {
client, _err := CreateClient()
if _err != nil {
return _err
}
getLeaveRecordsHeaders := &dingtalkattendance_1_0.GetLeaveRecordsHeaders{}
getLeaveRecordsHeaders.XAcsDingtalkAccessToken = tea.String("<your access token>")
getLeaveRecordsRequest := &dingtalkattendance_1_0.GetLeaveRecordsRequest{
OpUserId: tea.String("user01"),
LeaveCode: tea.String("f84a2dxxxx"),
UserIds: []*string{tea.String("user1")},
PageNumber: tea.Int64(1),
PageSize: tea.Int32(100),
}
tryErr := func()(_e error) {
defer func() {
if r := tea.Recover(recover()); r != nil {
_e = r
}
}()
_, _err = client.GetLeaveRecordsWithOptions(getLeaveRecordsRequest, getLeaveRecordsHeaders, &util.RuntimeOptions{})
if _err != nil {
return _err
}
return nil
}()
if tryErr != nil {
var err = &tea.SDKError{}
if _t, ok := tryErr.(*tea.SDKError); ok {
err = _t
} else {
err.Message = tea.String(tryErr.Error())
}
if !tea.BoolValue(util.Empty(err.Code)) && !tea.BoolValue(util.Empty(err.Message)) {
// err contains the code and message attributes to help developers locate the issue
}
}
return _err
}
func main() {
err := _main(tea.StringSlice(os.Args[1:]))
if err != nil {
panic(err)
}
}
// This file is auto-generated, don't edit it
import Util, * as $Util from '@alicloud/tea-util';
import dingtalkattendance_1_0, * as $dingtalkattendance_1_0 from '@alicloud/dingtalk/attendance_1_0';
import OpenApi, * as $OpenApi from '@alicloud/openapi-client';
import * as $tea from '@alicloud/tea-typescript';
export default class Client {
/**
* Initialize the account Client with a Token
* @return Client
* @throws Exception
*/
static createClient(): dingtalkattendance_1_0 {
let config = new $OpenApi.Config({ });
config.protocol = "https";
config.regionId = "central";
return new dingtalkattendance_1_0(config);
}
static async main(args: string[]): Promise<void> {
let client = Client.createClient();
let getLeaveRecordsHeaders = new $dingtalkattendance_1_0.GetLeaveRecordsHeaders({ });
getLeaveRecordsHeaders.xAcsDingtalkAccessToken = "<your access token>";
let getLeaveRecordsRequest = new $dingtalkattendance_1_0.GetLeaveRecordsRequest({
opUserId: "user01",
leaveCode: "f84a2dxxxx",
userIds: [
"user1"
],
pageNumber: 1,
pageSize: 100,
});
try {
await client.getLeaveRecordsWithOptions(getLeaveRecordsRequest, getLeaveRecordsHeaders, new $Util.RuntimeOptions({ }));
} catch (err) {
if (!Util.empty(err.code) && !Util.empty(err.message)) {
// err contains the code and message attributes to help developers locate the issue
}
}
}
}
Client.main(process.argv.slice(2));
// This file is auto-generated, don't edit it. Thanks.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Tea;
using Tea.Utils;
namespace AlibabaCloud.SDK.Sample
{
public class Sample
{
/**
* Initialize the account Client with a Token
* @return Client
* @throws Exception
*/
public static AlibabaCloud.SDK.Dingtalkattendance_1_0.Client CreateClient()
{
AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config();
config.Protocol = "https";
config.RegionId = "central";
return new AlibabaCloud.SDK.Dingtalkattendance_1_0.Client(config);
}
public static void Main(string[] args)
{
AlibabaCloud.SDK.Dingtalkattendance_1_0.Client client = CreateClient();
AlibabaCloud.SDK.Dingtalkattendance_1_0.Models.GetLeaveRecordsHeaders getLeaveRecordsHeaders = new AlibabaCloud.SDK.Dingtalkattendance_1_0.Models.GetLeaveRecordsHeaders();
getLeaveRecordsHeaders.XAcsDingtalkAccessToken = "<your access token>";
AlibabaCloud.SDK.Dingtalkattendance_1_0.Models.GetLeaveRecordsRequest getLeaveRecordsRequest = new AlibabaCloud.SDK.Dingtalkattendance_1_0.Models.GetLeaveRecordsRequest
{
OpUserId = "user01",
LeaveCode = "f84a2dxxxx",
UserIds = new List<string>
{
"user1"
},
PageNumber = 1,
PageSize = 100,
};
try
{
client.GetLeaveRecordsWithOptions(getLeaveRecordsRequest, getLeaveRecordsHeaders, new AlibabaCloud.TeaUtil.Models.RuntimeOptions());
}
catch (TeaException err)
{
if (!AlibabaCloud.TeaUtil.Common.Empty(err.Code) && !AlibabaCloud.TeaUtil.Common.Empty(err.Message))
{
// err contains the code and message attributes to help developers locate the issue
}
}
catch (Exception _err)
{
TeaException err = new TeaException(new Dictionary<string, object>
{
{ "message", _err.Message }
});
if (!AlibabaCloud.TeaUtil.Common.Empty(err.Code) && !AlibabaCloud.TeaUtil.Common.Empty(err.Message))
{
// err contains the code and message attributes to help developers locate the issue
}
}
}
}
}
Response
Response Body
| Name | Type | Description |
|---|---|---|
| result | Object | The returned result. |
| hasMore | Boolean | Whether more results exist. - true: More results exist. - false: No more results exist. |
| leaveRecords | Array | The list of leave consumption records. |
| userId | String | The userId of the employee. |
| leaveCode | String | The unique identifier of the leave type. |
| recordId | String | The unique identifier of the leave consumption record. |
| quotaId | String | The unique identifier of the leave quota. |
| calType | String | The calculation type. - insert: New record - add: Added - delete: Deleted - update: Updated - null (or the field is not returned): Consumed by a leave request |
| startTime | Long | The start time of the quota validity period or the leave request, as a timestamp in milliseconds. |
| endTime | Long | The end time of the quota validity period or the leave request, as a timestamp in milliseconds. |
| leaveViewUnit | String | The display unit. - day: Day - hour: Hour |
| leaveReason | String | The reason. |
| leaveRecordType | String | The leave record type. - leave: Leave request - update: Quota update - modify_quota: Balance initialization or balance update |
| leaveStatus | String | The leave request status. - init: The leave request is pending. - success: The leave request is approved. - refuse: The leave request is rejected. - abort: The leave request is withdrawn. - revoke: The leave request was approved, and its revocation request was then accepted. |
| recordNumPerDay | Long | The quota consumed, calculated in days. - Note When the leave type is calculated by day, this value is not empty and is measured in hundredths of a day. For example, 1000 = 10 days. |
| recordNumPerHour | Long | The quota consumed, calculated in hours. - Note When the leave type is calculated by hour, this value is not empty and is measured in hundredths of an hour. For example, 1000 = 10 hours. |
| gmtCreate | Long | The created time of the record, as a timestamp in milliseconds. |
| gmtModified | Long | The modified time of the record, as a timestamp in milliseconds. |
| opUserId | String | The ID of the operator of the record. |
| success | Boolean | Whether the request succeeded. - true: Yes - false: No |
Response Body Example
HTTP/1.1 200 OK
Content-Type:application/json
{
"result" : {
"hasMore" : true,
"leaveRecords" : [ {
"userId" : "user1",
"leaveCode" : "f84a2dxxxx",
"recordId" : "db1d74xxxxbaa",
"quotaId" : "db1d74xxxxbaa",
"calType" : "add",
"startTime" : 1653851001000,
"endTime" : 1753851001000,
"leaveViewUnit" : "day",
"leaveReason" : "Imported by admin",
"leaveRecordType" : "update",
"leaveStatus" : "init",
"recordNumPerDay" : 100,
"recordNumPerHour" : 100,
"gmtCreate" : 1653851001000,
"gmtModified" : 1753851001000,
"opUserId" : "manage2323"
} ]
},
"success" : true
}
Error Codes
If a call to this API fails, find a solution in the Global error codes document based on the error message.| HttpCode | Error Code | Error Message | Description |
|---|---|---|---|
| 400 | userNotExist | User does not exist | The user does not exist. |
| 400 | leaveOpuserIdIsNotAdmin | Non-admins can only query their own information | Non-admins can only query their own information. |
| 400 | leaveTypeNotFound | Leave type not found | The leave type was not found. |
| 400 | paramterInvalid | Parameter error | The opUserId and userId parameters cannot be empty. |
| 400 | leaveUserIdListMax | A maximum of 50 records can be queried at a time | Query up to 50 employee userIds at a time. |
| 400 | pageIndexIllegal | Pagination parameter error | The pagination parameter must be a non-negative integer starting from 0. |
| 400 | pageSizeIllegal | Page size exceeds the limit | The maximum page size is 200. |
| 400 | noPermission | No access permission | No access permission. |
| 400 | leaveOrgIsUsed | Access is allowed for organizations only | Only organizations can access this API. |