API call description
After adding a storage space, call this API to add a folder in the space.- When the storage space type is USER, all users with permissions on the space have operation permissions. Other employees must call the Add permissions API to grant authorization.
- When the storage space type is APP, anyone performing the operation must call the Add permissions API to grant authorization.
Request
Basic information
| Field | Value |
|---|---|
| HTTP URL | https://api.dingtalk.io/v1.0/storage/spaces/{spaceId}/dentries/{parentId}/folders |
| HTTP Method | POST |
| Supported app types | appType-Internal app appType-Third-party enterprise app |
| Permission required | permission-Storage.File.Write-Organization storage file write permission |
Request header
| Name | Type | Required | Description |
|---|---|---|---|
| x-acs-dingtalk-access-token | String | Yes | The access credential for calling this API. Obtain it as follows: - For an internal app, call the Get the access token of an internal app API to obtain it. - For a third-party enterprise app, call the Get the access token of an enterprise authorized to a third-party app API to obtain it. |
Path parameter
| Name | Type | Required | Description |
|---|---|---|---|
| spaceId | String | Yes | The space ID. Call the Add a space API to obtain the value of the id parameter. |
| parentId | String | Yes | The parent directory ID. Call the Get the list of files or folders API to obtain it. For the root directory, set this parameter to 0. |
Query parameter
| Name | Type | Required | Description |
|---|---|---|---|
| unionId | String | Yes | The unionId of the operator. Call the Query user details API to obtain it. |
Request body
| Name | Type | Required | Description | |
|---|---|---|---|---|
| name | String | Yes | The name of the folder. Naming requirements:- No leading or trailing spaces. Otherwise, they are automatically removed. - No special characters, including: tab, *, ", <, >, ` | . - Cannot end with .`. |
| option | Object | No | Optional parameters. | |
| conflictStrategy | String | No | The conflict strategy for folder names. - AUTO_RENAME: Automatically rename. Default value. - OVERWRITE: Overwrite. - RETURN_DENTRY_IF_EXISTS: Return the existing folder. - RETURN_ERROR_IF_EXISTS: Return an error if the folder already exists. | |
| appProperties | Array | No | The app property list of the current folder. Maximum value: 3. | |
| name | String | Yes | The property name. | |
| value | String | Yes | The property value. | |
| visibility | String | Yes | The property visibility. - PUBLIC: Visible to all apps. - PRIVATE: Visible only to the current app. |
Request example
HTTPPOST /v1.0/storage/spaces/833xxxxx/dentries/0/folders?unionId=cHtUxxxxx HTTP/1.1
Host:api.dingtalk.io
x-acs-dingtalk-access-token:xxxxx
Content-Type:application/json
{
"name" : "Test folder",
"option" : {
"conflictStrategy" : "AUTO_RENAME",
"appProperties" : [ {
"name" : "Attribute1",
"value" : "AttributeValue1",
"visibility" : "PUBLIC"
} ]
}
}
// 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 the Token
* @return Client
* @throws Exception
*/
public static com.aliyun.dingtalkstorage_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.dingtalkstorage_1_0.Client(config);
}
public static void main(String[] args_) throws Exception {
java.util.List<String> args = java.util.Arrays.asList(args_);
com.aliyun.dingtalkstorage_1_0.Client client = Sample.createClient();
com.aliyun.dingtalkstorage_1_0.models.AddFolderHeaders addFolderHeaders = new com.aliyun.dingtalkstorage_1_0.models.AddFolderHeaders();
addFolderHeaders.xAcsDingtalkAccessToken = "<your access token>";
com.aliyun.dingtalkstorage_1_0.models.AddFolderRequest.AddFolderRequestOptionAppProperties optionAppProperties0 = new com.aliyun.dingtalkstorage_1_0.models.AddFolderRequest.AddFolderRequestOptionAppProperties()
.setName("Attribute1")
.setValue("AttributeValue1")
.setVisibility("PUBLIC");
com.aliyun.dingtalkstorage_1_0.models.AddFolderRequest.AddFolderRequestOption option = new com.aliyun.dingtalkstorage_1_0.models.AddFolderRequest.AddFolderRequestOption()
.setConflictStrategy("AUTO_RENAME")
.setAppProperties(java.util.Arrays.asList(
optionAppProperties0
));
com.aliyun.dingtalkstorage_1_0.models.AddFolderRequest addFolderRequest = new com.aliyun.dingtalkstorage_1_0.models.AddFolderRequest()
.setUnionId("cHtUxxxxx")
.setName("Test folder")
.setOption(option);
try {
client.addFolderWithOptions("833xxxxx", "0", addFolderRequest, addFolderHeaders, 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 code and message properties to help you troubleshoot
}
} 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 code and message properties to help you troubleshoot
}
}
}
}
# -*- coding: utf-8 -*-
# This file is auto-generated, don't edit it. Thanks.
import sys
from typing import List
from alibabacloud_dingtalk.storage_1_0.client import Client as dingtalkstorage_1_0Client
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_dingtalk.storage_1_0 import models as dingtalkstorage__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() -> dingtalkstorage_1_0Client:
"""
Initialize the account Client with the Token
@return: Client
@throws Exception
"""
config = open_api_models.Config()
config.protocol = 'https'
config.region_id = 'central'
return dingtalkstorage_1_0Client(config)
@staticmethod
def main(
args: List[str],
) -> None:
client = Sample.create_client()
add_folder_headers = dingtalkstorage__1__0_models.AddFolderHeaders()
add_folder_headers.x_acs_dingtalk_access_token = '<your access token>'
option_app_properties_0 = dingtalkstorage__1__0_models.AddFolderRequestOptionAppProperties(
name='Attribute1',
value='AttributeValue1',
visibility='PUBLIC'
)
option = dingtalkstorage__1__0_models.AddFolderRequestOption(
conflict_strategy='AUTO_RENAME',
app_properties=[
option_app_properties_0
]
)
add_folder_request = dingtalkstorage__1__0_models.AddFolderRequest(
union_id='cHtUxxxxx',
name='Test folder',
option=option
)
try:
client.add_folder_with_options('833xxxxx', '0', add_folder_request, add_folder_headers, util_models.RuntimeOptions())
except Exception as err:
if not UtilClient.empty(err.code) and not UtilClient.empty(err.message):
# err contains code and message properties to help you troubleshoot
pass
@staticmethod
async def main_async(
args: List[str],
) -> None:
client = Sample.create_client()
add_folder_headers = dingtalkstorage__1__0_models.AddFolderHeaders()
add_folder_headers.x_acs_dingtalk_access_token = '<your access token>'
option_app_properties_0 = dingtalkstorage__1__0_models.AddFolderRequestOptionAppProperties(
name='Attribute1',
value='AttributeValue1',
visibility='PUBLIC'
)
option = dingtalkstorage__1__0_models.AddFolderRequestOption(
conflict_strategy='AUTO_RENAME',
app_properties=[
option_app_properties_0
]
)
add_folder_request = dingtalkstorage__1__0_models.AddFolderRequest(
union_id='cHtUxxxxx',
name='Test folder',
option=option
)
try:
await client.add_folder_with_options_async('833xxxxx', '0', add_folder_request, add_folder_headers, util_models.RuntimeOptions())
except Exception as err:
if not UtilClient.empty(err.code) and not UtilClient.empty(err.message):
# err contains code and message properties to help you troubleshoot
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\Vstorage_1_0\Dingtalk;
use \Exception;
use AlibabaCloud\Tea\Exception\TeaError;
use AlibabaCloud\Tea\Utils\Utils;
use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\SDK\Dingtalk\Vstorage_1_0\Models\AddFolderHeaders;
use AlibabaCloud\SDK\Dingtalk\Vstorage_1_0\Models\AddFolderRequest\option\appProperties;
use AlibabaCloud\SDK\Dingtalk\Vstorage_1_0\Models\AddFolderRequest\option;
use AlibabaCloud\SDK\Dingtalk\Vstorage_1_0\Models\AddFolderRequest;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
class Sample {
/**
* Initialize the account Client with 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();
$addFolderHeaders = new AddFolderHeaders([]);
$addFolderHeaders->xAcsDingtalkAccessToken = "<your access token>";
$optionAppProperties0 = new appProperties([
"name" => "Attribute1",
"value" => "AttributeValue1",
"visibility" => "PUBLIC"
]);
$option = new option([
"conflictStrategy" => "AUTO_RENAME",
"appProperties" => [
$optionAppProperties0
]
]);
$addFolderRequest = new AddFolderRequest([
"unionId" => "cHtUxxxxx",
"name" => "Test folder",
"option" => $option
]);
try {
$client->addFolderWithOptions("833xxxxx", "0", $addFolderRequest, $addFolderHeaders, 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 code and message properties to help you troubleshoot
}
}
}
}
$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/service"
dingtalkstorage_1_0 "github.com/alibabacloud-go/dingtalk/storage_1_0"
openapi "github.com/alibabacloud-go/darabonba-openapi/client"
"github.com/alibabacloud-go/tea/tea"
)
/**
* Initialize the account Client with the Token
* @return Client
* @throws Exception
*/
func CreateClient () (_result *dingtalkstorage_1_0.Client, _err error) {
config := &openapi.Config{}
config.Protocol = tea.String("https")
config.RegionId = tea.String("central")
_result = &dingtalkstorage_1_0.Client{}
_result, _err = dingtalkstorage_1_0.NewClient(config)
return _result, _err
}
func _main (args []*string) (_err error) {
client, _err := CreateClient()
if _err != nil {
return _err
}
addFolderHeaders := &dingtalkstorage_1_0.AddFolderHeaders{}
addFolderHeaders.XAcsDingtalkAccessToken = tea.String("<your access token>")
optionAppProperties0 := &dingtalkstorage_1_0.AddFolderRequestOptionAppProperties{
Name: tea.String("Attribute1"),
Value: tea.String("AttributeValue1"),
Visibility: tea.String("PUBLIC"),
}
option := &dingtalkstorage_1_0.AddFolderRequestOption{
ConflictStrategy: tea.String("AUTO_RENAME"),
AppProperties: []*dingtalkstorage_1_0.AddFolderRequestOptionAppProperties{optionAppProperties0},
}
addFolderRequest := &dingtalkstorage_1_0.AddFolderRequest{
UnionId: tea.String("cHtUxxxxx"),
Name: tea.String("Test folder"),
Option: option,
}
tryErr := func()(_e error) {
defer func() {
if r := tea.Recover(recover()); r != nil {
_e = r
}
}()
_, _err = client.AddFolderWithOptions(tea.String("833xxxxx"), tea.String("0"), addFolderRequest, addFolderHeaders, &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 code and message properties to help you troubleshoot
}
}
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 dingtalkstorage_1_0, * as $dingtalkstorage_1_0 from '@alicloud/dingtalk/storage_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 the Token
* @return Client
* @throws Exception
*/
static createClient(): dingtalkstorage_1_0 {
let config = new $OpenApi.Config({ });
config.protocol = "https";
config.regionId = "central";
return new dingtalkstorage_1_0(config);
}
static async main(args: string[]): Promise<void> {
let client = Client.createClient();
let addFolderHeaders = new $dingtalkstorage_1_0.AddFolderHeaders({ });
addFolderHeaders.xAcsDingtalkAccessToken = "<your access token>";
let optionAppProperties0 = new $dingtalkstorage_1_0.AddFolderRequestOptionAppProperties({
name: "Attribute1",
value: "AttributeValue1",
visibility: "PUBLIC",
});
let option = new $dingtalkstorage_1_0.AddFolderRequestOption({
conflictStrategy: "AUTO_RENAME",
appProperties: [
optionAppProperties0
],
});
let addFolderRequest = new $dingtalkstorage_1_0.AddFolderRequest({
unionId: "cHtUxxxxx",
name: "Test folder",
option: option,
});
try {
await client.addFolderWithOptions("833xxxxx", "0", addFolderRequest, addFolderHeaders, new $Util.RuntimeOptions({ }));
} catch (err) {
if (!Util.empty(err.code) && !Util.empty(err.message)) {
// err contains code and message properties to help you troubleshoot
}
}
}
}
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 the Token
* @return Client
* @throws Exception
*/
public static AlibabaCloud.SDK.Dingtalkstorage_1_0.Client CreateClient()
{
AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config();
config.Protocol = "https";
config.RegionId = "central";
return new AlibabaCloud.SDK.Dingtalkstorage_1_0.Client(config);
}
public static void Main(string[] args)
{
AlibabaCloud.SDK.Dingtalkstorage_1_0.Client client = CreateClient();
AlibabaCloud.SDK.Dingtalkstorage_1_0.Models.AddFolderHeaders addFolderHeaders = new AlibabaCloud.SDK.Dingtalkstorage_1_0.Models.AddFolderHeaders();
addFolderHeaders.XAcsDingtalkAccessToken = "<your access token>";
AlibabaCloud.SDK.Dingtalkstorage_1_0.Models.AddFolderRequest.AddFolderRequestOption.AddFolderRequestOptionAppProperties optionAppProperties0 = new AlibabaCloud.SDK.Dingtalkstorage_1_0.Models.AddFolderRequest.AddFolderRequestOption.AddFolderRequestOptionAppProperties
{
Name = "Attribute1",
Value = "AttributeValue1",
Visibility = "PUBLIC",
};
AlibabaCloud.SDK.Dingtalkstorage_1_0.Models.AddFolderRequest.AddFolderRequestOption option = new AlibabaCloud.SDK.Dingtalkstorage_1_0.Models.AddFolderRequest.AddFolderRequestOption
{
ConflictStrategy = "AUTO_RENAME",
AppProperties = new List<AlibabaCloud.SDK.Dingtalkstorage_1_0.Models.AddFolderRequest.AddFolderRequestOption.AddFolderRequestOptionAppProperties>
{
optionAppProperties0
},
};
AlibabaCloud.SDK.Dingtalkstorage_1_0.Models.AddFolderRequest addFolderRequest = new AlibabaCloud.SDK.Dingtalkstorage_1_0.Models.AddFolderRequest
{
UnionId = "cHtUxxxxx",
Name = "Test folder",
Option = option,
};
try
{
client.AddFolderWithOptions("833xxxxx", "0", addFolderRequest, addFolderHeaders, new AlibabaCloud.TeaUtil.Models.RuntimeOptions());
}
catch (TeaException err)
{
if (!AlibabaCloud.TeaUtil.Common.Empty(err.Code) && !AlibabaCloud.TeaUtil.Common.Empty(err.Message))
{
// err contains code and message properties to help you troubleshoot
}
}
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 code and message properties to help you troubleshoot
}
}
}
}
}
Response
Response body
| Name | Type | Description |
|---|---|---|
| dentry | Object | The folder information. |
| id | String | The folder ID. |
| spaceId | String | The ID of the space where the folder resides. |
| parentId | String | The parent directory ID. A value of 0 indicates the root directory. |
| type | String | The type. This API returns a fixed value. - FOLDER: Folder. |
| name | String | The name of the folder. |
| size | Long | The size, in bytes. This API does not return this field when adding a folder. |
| path | String | The path of the folder within the space. |
| version | Long | The version. This API does not return this field when adding a folder. |
| status | String | The status. - NORMAL: Normal. - DELETED: Deleted. |
| extension | String | The extension. This API does not return this field when adding a folder. |
| creatorId | String | The unionId of the creator. |
| modifierId | String | The unionId of the modifier. |
| createTime | String | The created time in ISO 8601 format. Example: 2022-07-29T14:55Z. |
| modifiedTime | String | The modified time in ISO 8601 format. Example: 2022-07-29T14:55Z. |
| properties | Object | The folder properties. |
| readOnly | Boolean | Whether the folder is read-only. - true: Yes. - false: No. |
| appProperties | Map<String, Array> | The properties on a specific app. The key is the ownerId of the space, and the value is the property list. |
| Array | The property list. | |
| name | String | The property name. |
| value | String | The property value. |
| visibility | String | The property visibility. - PUBLIC: Visible to all apps. - PRIVATE: Visible only to the current app. |
| uuid | String | The identifier field. |
| partitionType | String | The storage partition. - PUBLIC_OSS_PARTITION: Public Cloud OSS storage partition. - MINI_OSS_PARTITION: Dedicated MiniOSS storage partition. |
| storageDriver | String | The driver type. - DINGTALK: DingTalk unified storage driver. - ALIDOC: DingTalk Docs storage driver. - UNKNOWN: Unknown driver. |
Response body example
HTTP/1.1 200 OK
Content-Type:application/json
{
"dentry" : {
"id" : "123",
"spaceId" : "854xxxxx",
"parentId" : "0",
"type" : "FOLDER",
"name" : "Test folder",
"size" : 512,
"path" : "/Test folder",
"version" : 1,
"status" : "NORMAL",
"extension" : "txt",
"creatorId" : "cHtUxxxxx",
"modifierId" : "modifier_id",
"createTime" : "2022-01-01T10:00:00Z",
"modifiedTime" : "2022-01-01T10:00:00Z",
"properties" : {
"readOnly" : true
},
"appProperties" : [ {
"name" : "property_name",
"value" : "property_value",
"visibility" : "PRIVATE"
} ],
"uuid" : "uuid",
"partitionType" : "PUBLIC_OSS_PARTITION",
"storageDriver" : "DINGTALK"
}
}
Error codes
If an error is returned when calling this API, refer to the Global error codes document to find a solution based on the error message.| HttpCode | Error code | Error message | Description |
|---|---|---|---|
| 400 | operationConcurrentControl | %s | Concurrency control. |
| 400 | paramError | %s | Parameter error. |
| 400 | paramError.conflictStrategy | %s | Parameter error - conflictStrategy. |
| 400 | dentryNameIllegal | %s | Illegal file name. |
| 400 | dentryAlreadyExist | %s | File already exists. |
| 403 | permissionDenied | %s | The user lacks the permission to add a folder. |
| 404 | dentryNotExist | %s | The parent directory does not exist. |
| 500 | systemError | %s | System error. |
| 500 | unknownError | Unknown Error | Unknown error. |
| 503 | operationTimeout | %s | Request timed out. |