授权预览审批附件
调用本接口,授权预览审批附件。
接口调用流程
本接口需配合钉盘JSAPI使用。
-
获取审批钉盘空间spaceId,调用获取审批钉盘空间信息接口,获取审批钉盘空间spaceId。
-
根据审批钉盘空间spaceId,网页应用(H5微应用)/小程序,通过上传附件到钉盘/从钉盘选择文件获取钉盘附件file的信息。
-
获取审批实例processInstanceId,调用发起审批实例接口获取InstanceId参数值。
-
根据上述获取信息,调用本接口,授权用户审批附件预览权限。每一次预览审批附件前,都需要调用本接口进行授权。
-
调用预览钉盘文件接口,进行预览,调用预览钉盘文件接口。
权限
要调用此API,需要以下权限之一。
应用类型 |
是否支持 |
权限 |
API Explorer调试 |
|---|---|---|---|
| 企业内部应用 | 支持 | 工作流实例写权限 | API Explorer |
| 第三方企业应用 | 支持 | 工作流实例写权限 | API Explorer |
| 第三方个人应用 | 暂不支持 | 暂不支持 | 暂不支持 |
请求方法
POST /v1.0/workflow/processInstances/spaces/authPreview HTTP/1.1
x-acs-dingtalk-access-token:String
Content-Type:application/json
{
"userId" : "String",
"agentId" : Long,
"processInstanceId" : "String",
"fileId" : "String",
"fileIdList" : [ "String" ],
"withCommentAttatchment" : Boolean
}
Header参数
名称 |
类型 |
是否必填 |
描述 |
|---|---|---|---|
x-acs-dingtalk-access-token |
String |
是 |
调用该接口的访问凭证。
|
Body参数
名称 |
类型 |
是否必填 |
描述 |
|---|---|---|---|
userId |
String |
是 |
授权允许预览附件的用户userId。 |
agentId |
Long |
否 |
应用的agentId:
|
processInstanceId |
String |
是 |
审批实例ID。
|
fileId |
String |
是 |
审批附件ID。 说明
fileId必须与发起审批实例中附件组件中的文件fileId保持一致,否则出现无权限错误信息。 |
fileIdList |
Array of String |
否 |
附件ID列表,支持批量授权,最大列表长度为20。 |
withCommentAttatchment |
Boolean |
否 |
是否包含评论中的附件,默认忽略评论中附件。 |
返回参数
名称 |
类型 |
描述 |
|---|---|---|
result |
Object |
返回结果。 |
spaceId |
Long |
钉盘空间ID。 |
success |
Boolean |
接口调用是否成功。 |
示例
请求示例
POST /v1.0/workflow/processInstances/spaces/authPreview HTTP/1.1
Host:api.dingtalk.com
x-acs-dingtalk-access-token:6d1bxxxx
Content-Type:application/json
{
"userId" : "user123",
"agentId" : 8345000,
"processInstanceId" : "a17444d1-075b-4a4d-xxxx",
"fileId" : "111",
"fileIdList" : [ "123" ]
}// This file is auto-generated, don't edit it. Thanks.
package com.aliyun.sample;
import com.aliyun.tea.*;
public class Sample {
/**
* 使用 Token 初始化账号Client
* @return Client
* @throws Exception
*/
public static com.aliyun.dingtalkworkflow_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.dingtalkworkflow_1_0.Client(config);
}
public static void main(String[] args_) throws Exception {
java.util.List<String> args = java.util.Arrays.asList(args_);
com.aliyun.dingtalkworkflow_1_0.Client client = Sample.createClient();
com.aliyun.dingtalkworkflow_1_0.models.GetSpaceWithDownloadAuthHeaders getSpaceWithDownloadAuthHeaders = new com.aliyun.dingtalkworkflow_1_0.models.GetSpaceWithDownloadAuthHeaders();
getSpaceWithDownloadAuthHeaders.xAcsDingtalkAccessToken = "<your access token>";
com.aliyun.dingtalkworkflow_1_0.models.GetSpaceWithDownloadAuthRequest getSpaceWithDownloadAuthRequest = new com.aliyun.dingtalkworkflow_1_0.models.GetSpaceWithDownloadAuthRequest()
.setUserId("user123")
.setAgentId(8345000L)
.setProcessInstanceId("a17444d1-075b-4a4d-xxxx")
.setFileId("111")
.setFileIdList(java.util.Arrays.asList(
"123"
));
try {
client.getSpaceWithDownloadAuthWithOptions(getSpaceWithDownloadAuthRequest, getSpaceWithDownloadAuthHeaders, 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 中含有 code 和 message 属性,可帮助开发定位问题
}
} 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 中含有 code 和 message 属性,可帮助开发定位问题
}
}
}
}# -*- coding: utf-8 -*-
# This file is auto-generated, don't edit it. Thanks.
import sys
from typing import List
from alibabacloud_dingtalk.workflow_1_0.client import Client as dingtalkworkflow_1_0Client
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_dingtalk.workflow_1_0 import models as dingtalkworkflow__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() -> dingtalkworkflow_1_0Client:
"""
使用 Token 初始化账号Client
@return: Client
@throws Exception
"""
config = open_api_models.Config()
config.protocol = 'https'
config.region_id = 'central'
return dingtalkworkflow_1_0Client(config)
@staticmethod
def main(
args: List[str],
) -> None:
client = Sample.create_client()
get_space_with_download_auth_headers = dingtalkworkflow__1__0_models.GetSpaceWithDownloadAuthHeaders()
get_space_with_download_auth_headers.x_acs_dingtalk_access_token = '<your access token>'
get_space_with_download_auth_request = dingtalkworkflow__1__0_models.GetSpaceWithDownloadAuthRequest(
user_id='user123',
agent_id=8345000,
process_instance_id='a17444d1-075b-4a4d-xxxx',
file_id='111',
file_id_list=[
'123'
]
)
try:
client.get_space_with_download_auth_with_options(get_space_with_download_auth_request, get_space_with_download_auth_headers, util_models.RuntimeOptions())
except Exception as err:
if not UtilClient.empty(err.code) and not UtilClient.empty(err.message):
# err 中含有 code 和 message 属性,可帮助开发定位问题
pass
@staticmethod
async def main_async(
args: List[str],
) -> None:
client = Sample.create_client()
get_space_with_download_auth_headers = dingtalkworkflow__1__0_models.GetSpaceWithDownloadAuthHeaders()
get_space_with_download_auth_headers.x_acs_dingtalk_access_token = '<your access token>'
get_space_with_download_auth_request = dingtalkworkflow__1__0_models.GetSpaceWithDownloadAuthRequest(
user_id='user123',
agent_id=8345000,
process_instance_id='a17444d1-075b-4a4d-xxxx',
file_id='111',
file_id_list=[
'123'
]
)
try:
await client.get_space_with_download_auth_with_options_async(get_space_with_download_auth_request, get_space_with_download_auth_headers, util_models.RuntimeOptions())
except Exception as err:
if not UtilClient.empty(err.code) and not UtilClient.empty(err.message):
# err 中含有 code 和 message 属性,可帮助开发定位问题
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\Vworkflow_1_0\Dingtalk;
use \Exception;
use AlibabaCloud\Tea\Exception\TeaError;
use AlibabaCloud\Tea\Utils\Utils;
use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\SDK\Dingtalk\Vworkflow_1_0\Models\GetSpaceWithDownloadAuthHeaders;
use AlibabaCloud\SDK\Dingtalk\Vworkflow_1_0\Models\GetSpaceWithDownloadAuthRequest;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
class Sample {
/**
* 使用 Token 初始化账号Client
* @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();
$getSpaceWithDownloadAuthHeaders = new GetSpaceWithDownloadAuthHeaders([]);
$getSpaceWithDownloadAuthHeaders->xAcsDingtalkAccessToken = "<your access token>";
$getSpaceWithDownloadAuthRequest = new GetSpaceWithDownloadAuthRequest([
"userId" => "user123",
"agentId" => 8345000,
"processInstanceId" => "a17444d1-075b-4a4d-xxxx",
"fileId" => "111",
"fileIdList" => [
"123"
]
]);
try {
$client->getSpaceWithDownloadAuthWithOptions($getSpaceWithDownloadAuthRequest, $getSpaceWithDownloadAuthHeaders, 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 中含有 code 和 message 属性,可帮助开发定位问题
}
}
}
}
$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"
dingtalkworkflow_1_0 "github.com/alibabacloud-go/dingtalk/workflow_1_0"
openapi "github.com/alibabacloud-go/darabonba-openapi/client"
"github.com/alibabacloud-go/tea/tea"
)
/**
* 使用 Token 初始化账号Client
* @return Client
* @throws Exception
*/
func CreateClient () (_result *dingtalkworkflow_1_0.Client, _err error) {
config := &openapi.Config{}
config.Protocol = tea.String("https")
config.RegionId = tea.String("central")
_result = &dingtalkworkflow_1_0.Client{}
_result, _err = dingtalkworkflow_1_0.NewClient(config)
return _result, _err
}
func _main (args []*string) (_err error) {
client, _err := CreateClient()
if _err != nil {
return _err
}
getSpaceWithDownloadAuthHeaders := &dingtalkworkflow_1_0.GetSpaceWithDownloadAuthHeaders{}
getSpaceWithDownloadAuthHeaders.XAcsDingtalkAccessToken = tea.String("<your access token>")
getSpaceWithDownloadAuthRequest := &dingtalkworkflow_1_0.GetSpaceWithDownloadAuthRequest{
UserId: tea.String("user123"),
AgentId: tea.Int64(8345000),
ProcessInstanceId: tea.String("a17444d1-075b-4a4d-xxxx"),
FileId: tea.String("111"),
FileIdList: []*string{tea.String("123")},
}
tryErr := func()(_e error) {
defer func() {
if r := tea.Recover(recover()); r != nil {
_e = r
}
}()
_, _err = client.GetSpaceWithDownloadAuthWithOptions(getSpaceWithDownloadAuthRequest, getSpaceWithDownloadAuthHeaders, &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 中含有 code 和 message 属性,可帮助开发定位问题
}
}
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 dingtalkworkflow_1_0, * as $dingtalkworkflow_1_0 from '@alicloud/dingtalk/workflow_1_0';
import OpenApi, * as $OpenApi from '@alicloud/openapi-client';
import * as $tea from '@alicloud/tea-typescript';
export default class Client {
/**
* 使用 Token 初始化账号Client
* @return Client
* @throws Exception
*/
static createClient(): dingtalkworkflow_1_0 {
let config = new $OpenApi.Config({ });
config.protocol = "https";
config.regionId = "central";
return new dingtalkworkflow_1_0(config);
}
static async main(args: string[]): Promise<void> {
let client = Client.createClient();
let getSpaceWithDownloadAuthHeaders = new $dingtalkworkflow_1_0.GetSpaceWithDownloadAuthHeaders({ });
getSpaceWithDownloadAuthHeaders.xAcsDingtalkAccessToken = "<your access token>";
let getSpaceWithDownloadAuthRequest = new $dingtalkworkflow_1_0.GetSpaceWithDownloadAuthRequest({
userId: "user123",
agentId: 8345000,
processInstanceId: "a17444d1-075b-4a4d-xxxx",
fileId: "111",
fileIdList: [
"123"
],
});
try {
await client.getSpaceWithDownloadAuthWithOptions(getSpaceWithDownloadAuthRequest, getSpaceWithDownloadAuthHeaders, new $Util.RuntimeOptions({ }));
} catch (err) {
if (!Util.empty(err.code) && !Util.empty(err.message)) {
// err 中含有 code 和 message 属性,可帮助开发定位问题
}
}
}
}
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
{
/**
* 使用 Token 初始化账号Client
* @return Client
* @throws Exception
*/
public static AlibabaCloud.SDK.Dingtalkworkflow_1_0.Client CreateClient()
{
AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config();
config.Protocol = "https";
config.RegionId = "central";
return new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Client(config);
}
public static void Main(string[] args)
{
AlibabaCloud.SDK.Dingtalkworkflow_1_0.Client client = CreateClient();
AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.GetSpaceWithDownloadAuthHeaders getSpaceWithDownloadAuthHeaders = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.GetSpaceWithDownloadAuthHeaders();
getSpaceWithDownloadAuthHeaders.XAcsDingtalkAccessToken = "<your access token>";
AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.GetSpaceWithDownloadAuthRequest getSpaceWithDownloadAuthRequest = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.GetSpaceWithDownloadAuthRequest
{
UserId = "user123",
AgentId = 8345000,
ProcessInstanceId = "a17444d1-075b-4a4d-xxxx",
FileId = "111",
FileIdList = new List<string>
{
"123"
},
};
try
{
client.GetSpaceWithDownloadAuthWithOptions(getSpaceWithDownloadAuthRequest, getSpaceWithDownloadAuthHeaders, new AlibabaCloud.TeaUtil.Models.RuntimeOptions());
}
catch (TeaException err)
{
if (!AlibabaCloud.TeaUtil.Common.Empty(err.Code) && !AlibabaCloud.TeaUtil.Common.Empty(err.Message))
{
// err 中含有 code 和 message 属性,可帮助开发定位问题
}
}
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 中含有 code 和 message 属性,可帮助开发定位问题
}
}
}
}
}返回示例
HTTP/1.1 200 OK
Content-Type:application/json
{
"result" : {
"spaceId" : 3996960664
},
"success" : true
}
错误码
HttpCode |
错误码 |
错误信息 |
说明 |
|---|---|---|---|
400 |
invalidParameter |
授权预览审批附件参数错误 |
授权预览审批附件参数错误 |
400 |
userNotExist |
用户不存在 |
用户不存在 |
400 |
noPermission |
无权访问,企业没有开通相应的微应用 |
无权访问,企业没有开通相应的微应用 |
400 |
invalidUserId |
授权预览审批附件,用户userId不能为空 |
授权预览审批附件,用户userId不能为空 |
400 |
invalidProcessInstanceId |
授权预览审批附件,实例id不能为空 |
授权预览审批附件,实例id不能为空 |
400 |
invalidParameterCspace |
使用授权码方式认证时,isvOrgId不能为空 |
使用授权码方式认证时,isvOrgId不能为空 |
400 |
hsfIntegrationErrorCspaceGetCustomSpace |
获取钉盘space的信息失败 |
获取钉盘space的信息失败 |
400 |
hsfIntegrationErrorCspaceGetSimpleMicroAppByRelatedAppId |
根据relatedAppId查询获取微应用信息失败 |
根据relatedAppId查询获取微应用信息失败 |
400 |
hsfIntegrationErrorCspaceDentryServiceGrant |
授权访问钉盘失败 |
授权访问钉盘失败 |
400 |
hsfIntegrationErrorCspace |
钉盘附件依赖三方错误 |
钉盘附件依赖三方错误 |
400 |
invalidFileId |
授权预览审批附件,审批附件fileId不能为空 |
授权预览审批附件,审批附件fileId不能为空 |
400 |
invalidFileList |
授权预览审批附件,审批附件fileList不能为空 |
授权预览审批附件,审批附件fileList不能为空 |
400 |
processInstNotExist |
审批实例不存在 |
审批实例不存在 |
400 |
noPermission |
无访问权限 |
无访问权限 |
400 |
internalError |
%s |
系统内部异常 |
500 |
systemError |
系统异常 |
系统异常 |