Skip to main content

Get the information of a specified space by spaceId

Request

Basic information

FieldValue
HTTP URLhttps://api.dingtalk.io/v1.0/drive/managements/spaces/query
HTTP MethodPOST
Supported app typesappType-Internal app appType-Third-party enterprise app
Permission requirementspermission-Drive.SpaceManage.Read-Read permission for Drive app space management information

Request header

NameTypeRequiredDescription
x-acs-dingtalk-access-tokenStringYesThe access credential for calling this API. Obtain it in one of the following ways: - For an internal app, call the Get the access token of an internal app API. - For a third-party enterprise app, call the Get the access token of an organization authorized to a third-party app API.

Request body

NameTypeRequiredDescription
spaceIdsArray of StringYesThe list of space IDs. You can pass in up to 30 IDs. Call the Get the space list API to obtain them.
unionIdStringYesThe unionId of the user. Call the Query user details API to obtain it.

Request example

HTTP
POST /v1.0/drive/managements/spaces/query HTTP/1.1
Host:api.dingtalk.io
x-acs-dingtalk-access-token:2db66caxxxx
Content-Type:application/json

{
  "spaceIds" : [ "123" ],
  "unionId" : "sKUPRiijxxxxx"
}
Java
package com.aliyun.sample;

import com.aliyun.tea.*;

public class Sample {

    /**
     * <b>description</b> :
     * <p>Initialize the account client by using the token</p>
     * @return Client
     * 
     * @throws Exception
     */
    public static com.aliyun.dingtalkdrive_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.dingtalkdrive_1_0.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        
        com.aliyun.dingtalkdrive_1_0.Client client = Sample.createClient();
        com.aliyun.dingtalkdrive_1_0.models.ManagementListSpacesHeaders managementListSpacesHeaders = new com.aliyun.dingtalkdrive_1_0.models.ManagementListSpacesHeaders();
        managementListSpacesHeaders.xAcsDingtalkAccessToken = "<your access token>";
        com.aliyun.dingtalkdrive_1_0.models.ManagementListSpacesRequest managementListSpacesRequest = new com.aliyun.dingtalkdrive_1_0.models.ManagementListSpacesRequest()
                .setSpaceIds(java.util.Arrays.asList(
                    "123"
                ))
                .setUnionId("sKUPRiijxxxxx");
        try {
            client.managementListSpacesWithOptions(managementListSpacesRequest, managementListSpacesHeaders, new com.aliyun.teautil.models.RuntimeOptions());
        } catch (TeaException err) {
            if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
                // The err contains the code and message attributes, which help 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)) {
                // The err contains the code and message attributes, which help locate the issue
            }

        }        
    }
}
Python
# -*- coding: utf-8 -*-
# This file is auto-generated, don't edit it. Thanks.
import os
import sys
import json

from typing import List

from alibabacloud_dingtalk.drive_1_0.client import Client as dingtalkdrive_1_0Client
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_dingtalk.drive_1_0 import models as dingtalkdrive__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() -> dingtalkdrive_1_0Client:
        """
        Initialize the account client by using the token
        @return: Client
        @throws Exception
        """
        config = open_api_models.Config()
        config.protocol = 'https'
        config.region_id = 'central'
        return dingtalkdrive_1_0Client(config)

    @staticmethod
    def main(
        args: List[str],
    ) -> None:
        client = Sample.create_client()
        management_list_spaces_headers = dingtalkdrive__1__0_models.ManagementListSpacesHeaders()
        management_list_spaces_headers.x_acs_dingtalk_access_token = '<your access token>'
        management_list_spaces_request = dingtalkdrive__1__0_models.ManagementListSpacesRequest(
            space_ids=[
                '123'
            ],
            union_id='sKUPRiijxxxxx'
        )
        try:
            client.management_list_spaces_with_options(management_list_spaces_request, management_list_spaces_headers, util_models.RuntimeOptions())
        except Exception as err:
            if not UtilClient.empty(err.code) and not UtilClient.empty(err.message):
                # The err contains the code and message attributes, which help locate the issue
                pass

    @staticmethod
    async def main_async(
        args: List[str],
    ) -> None:
        client = Sample.create_client()
        management_list_spaces_headers = dingtalkdrive__1__0_models.ManagementListSpacesHeaders()
        management_list_spaces_headers.x_acs_dingtalk_access_token = '<your access token>'
        management_list_spaces_request = dingtalkdrive__1__0_models.ManagementListSpacesRequest(
            space_ids=[
                '123'
            ],
            union_id='sKUPRiijxxxxx'
        )
        try:
            await client.management_list_spaces_with_options_async(management_list_spaces_request, management_list_spaces_headers, util_models.RuntimeOptions())
        except Exception as err:
            if not UtilClient.empty(err.code) and not UtilClient.empty(err.message):
                # The err contains the code and message attributes, which help locate the issue
                pass

if __name__ == '__main__':
    Sample.main(sys.argv[1:])
PHP
<?php

// This file is auto-generated, don't edit it. Thanks.
namespace AlibabaCloud\SDK\Sample;

use AlibabaCloud\SDK\Dingtalk\Vdrive_1_0\Dingtalk;
use \Exception;
use AlibabaCloud\Tea\Exception\TeaError;
use AlibabaCloud\Tea\Utils\Utils;

use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\SDK\Dingtalk\Vdrive_1_0\Models\ManagementListSpacesHeaders;
use AlibabaCloud\SDK\Dingtalk\Vdrive_1_0\Models\ManagementListSpacesRequest;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;

class Sample {

    /**
     * Initialize the account client by using the 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();
        $managementListSpacesHeaders = new ManagementListSpacesHeaders([]);
        $managementListSpacesHeaders->xAcsDingtalkAccessToken = "<your access token>";
        $managementListSpacesRequest = new ManagementListSpacesRequest([
            "spaceIds" => [
                "123"
            ],
            "unionId" => "sKUPRiijxxxxx"
        ]);
        try {
            $client->managementListSpacesWithOptions($managementListSpacesRequest, $managementListSpacesHeaders, 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)) {
                // The err contains the code and message attributes, which help 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));
Go
package main

import (
  "encoding/json"
  "strings"
  "fmt"
  "os"
  util  "github.com/alibabacloud-go/tea-utils/v2/service"
  dingtalkdrive_1_0  "github.com/alibabacloud-go/dingtalk/drive_1_0"
  openapi  "github.com/alibabacloud-go/darabonba-openapi/v2/client"
  "github.com/alibabacloud-go/tea/tea"
)

// Description:
// 
// Initialize the account client by using the token
// 
// @return Client
// 
// @throws Exception
func CreateClient () (_result *dingtalkdrive_1_0.Client, _err error) {
  config := &openapi.Config{}
  config.Protocol = tea.String("https")
  config.RegionId = tea.String("central")
  _result = &dingtalkdrive_1_0.Client{}
  _result, _err = dingtalkdrive_1_0.NewClient(config)
  return _result, _err
}

func _main (args []*string) (_err error) {
  client, _err := CreateClient()
  if _err != nil {
    return _err
  }

  managementListSpacesHeaders := &dingtalkdrive_1_0.ManagementListSpacesHeaders{}
  managementListSpacesHeaders.XAcsDingtalkAccessToken = tea.String("<your access token>")
  managementListSpacesRequest := &dingtalkdrive_1_0.ManagementListSpacesRequest{
    SpaceIds: []*string{tea.String("123")},
    UnionId: tea.String("sKUPRiijxxxxx"),
  }
  tryErr := func()(_e error) {
    defer func() {
      if r := tea.Recover(recover()); r != nil {
        _e = r
      }
    }()
    _, _err = client.ManagementListSpacesWithOptions(managementListSpacesRequest, managementListSpacesHeaders, &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)) {
      // The err contains the code and message attributes, which help locate the issue
    }

  }
  return _err
}

func main() {
  err := _main(tea.StringSlice(os.Args[1:]))
  if err != nil {
    panic(err)
  }
}
Node.js
'use strict';
// This file is auto-generated, don't edit it
const Util = require('@alicloud/tea-util');
const dingtalkdrive_1_0 = require('@alicloud/dingtalk/drive_1_0');
const OpenApi = require('@alicloud/openapi-client');
const Tea = require('@alicloud/tea-typescript');

class Client {

  /**
   * Initialize the account client by using the token
   * @return Client
   * @throws Exception
   */
  static createClient() {
    let config = new OpenApi.Config({ });
    config.protocol = 'https';
    config.regionId = 'central';
    return new dingtalkdrive_1_0.default(config);
  }

  static async main(args) {
    let client = Client.createClient();
    let managementListSpacesHeaders = new dingtalkdrive_1_0.ManagementListSpacesHeaders({ });
    managementListSpacesHeaders.xAcsDingtalkAccessToken = '<your access token>';
    let managementListSpacesRequest = new dingtalkdrive_1_0.ManagementListSpacesRequest({
      spaceIds: [
        '123'
      ],
      unionId: 'sKUPRiijxxxxx',
    });
    try {
      await client.managementListSpacesWithOptions(managementListSpacesRequest, managementListSpacesHeaders, new Util.RuntimeOptions({ }));
    } catch (err) {
      if (!Util.default.empty(err.code) && !Util.default.empty(err.message)) {
        // The err contains the code and message attributes, which help locate the issue
      }

    }    
  }

}

exports.Client = Client;
Client.main(process.argv.slice(2));
C#
using Newtonsoft.Json;
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 
    {

        /// <term><b>Description:</b></term>
        /// <description>
        /// <para>Initialize the account client by using the token</para>
        /// </description>
        /// 
        /// <returns>
        /// Client
        /// </returns>
        /// 
        /// <term><b>Exception:</b></term>
        /// Exception
        public static AlibabaCloud.SDK.Dingtalkdrive_1_0.Client CreateClient()
        {
            AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config();
            config.Protocol = "https";
            config.RegionId = "central";
            return new AlibabaCloud.SDK.Dingtalkdrive_1_0.Client(config);
        }

        public static void Main(string[] args)
        {
            AlibabaCloud.SDK.Dingtalkdrive_1_0.Client client = CreateClient();
            AlibabaCloud.SDK.Dingtalkdrive_1_0.Models.ManagementListSpacesHeaders managementListSpacesHeaders = new AlibabaCloud.SDK.Dingtalkdrive_1_0.Models.ManagementListSpacesHeaders();
            managementListSpacesHeaders.XAcsDingtalkAccessToken = "<your access token>";
            AlibabaCloud.SDK.Dingtalkdrive_1_0.Models.ManagementListSpacesRequest managementListSpacesRequest = new AlibabaCloud.SDK.Dingtalkdrive_1_0.Models.ManagementListSpacesRequest
            {
                SpaceIds = new List<string>
                {
                    "123"
                },
                UnionId = "sKUPRiijxxxxx",
            };
            try
            {
                client.ManagementListSpacesWithOptions(managementListSpacesRequest, managementListSpacesHeaders, new AlibabaCloud.TeaUtil.Models.RuntimeOptions());
            }
            catch (TeaException err)
            {
                if (!AlibabaCloud.TeaUtil.Common.Empty(err.Code) && !AlibabaCloud.TeaUtil.Common.Empty(err.Message))
                {
                    // The err contains the code and message attributes, which help 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))
                {
                    // The err contains the code and message attributes, which help locate the issue
                }
            }
        }

    }
}

Response

Response body

NameTypeDescription
spacesArrayThe list of spaces.
spaceIdStringThe space ID.
spaceNameStringThe space name.
spaceTypeStringThe space type. - personal: Personal space - org: Organization space
quotaLongThe total quota of the space. - -1: The space quota is unlimited. If the space has organization attributes, it cannot exceed the organization space quota.
usedQuotaLongThe used quota of the space.
permissionModeStringThe authorization mode. Valid values: - acl: ACL authorization - custom: Custom authorization
createTimeStringThe created time, in ISO 8601 format, for example, 2022-07-29T14:55Z.
modifyTimeStringThe modified time, in ISO 8601 format, for example, 2022-07-29T14:55Z.

Response body example

HTTP/1.1 200 OK
Content-Type:application/json

{
  "spaces" : [ {
    "spaceId" : "123456789",
    "spaceName" : "Zhang San's shared folder",
    "spaceType" : "org",
    "quota" : 2147483648,
    "usedQuota" : 640445953,
    "permissionMode" : "acl",
    "createTime" : "2016-02-28T10:47:08Z",
    "modifyTime" : "2021-03-29T14:20:36Z"
  } ]
}

Error codes

If an error occurs when calling this API, find the solution by error message in the Global error codes documentation.
HttpCodeError codeError messageDescription
400param.errorInvalid ParamParameter error
500request.overlimitYou have sent too many requests.Requests are too frequent
500unsupported.operationDoes not support the operationThis operation is not supported
500no.priviledgeYou are not authorized to perform this operation.You are not authorized to perform this operation
500unknown.errorUnknown ErrorUnknown error