文档首页/ 需求管理 CodeArts Req/ API参考/ API/ Scrum项目的工作项/ 取消关联工作项 - CancelScrumAssociate
更新时间:2026-10-22 GMT+08:00
分享

取消关联工作项 - CancelScrumAssociate

功能介绍

取消两个工作项之间的关联关系。仅项目创建者、项目管理员、工作项责任人、创建人或具有编辑权限的角色可执行取消操作。

取消后会同步生成 journal 动态记录。

调用方法

请参见如何调用API。

授权信息

当前API调用无需身份策略权限。

URI

POST /v2/issues/cancel-associate

请求参数

表1 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

是

String

参数解释:

用户访问凭证。通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。

约束限制:

不涉及。

取值范围:

长度为10~32768个字符。

默认取值:

不涉及。

表2 请求Body参数

参数

是否必选

参数类型

描述

projectUUId

是

String

参数解释:

源项目UUID。标识执行取消关联操作的源工作项所属项目。

约束限制:

32位UUID字符串,必填字段。

取值范围:

32个字符,由小写字母和数字组成。

默认取值:

不涉及。

attachProjectUUId

否

String

参数解释:

目标项目UUID。标识被取消关联工作项所属的项目;跨项目取消时必填。

约束限制:

32位UUID字符串。

取值范围:

32个字符,由小写字母和数字组成。

默认取值:

不涉及。

issueId

是

Integer

参数解释:

源工作项ID。即需要解除关联关系的工作项唯一ID。

约束限制:

工作项必须存在且未被归档。

取值范围:

不涉及。

默认取值:

不涉及。

attachIssueId

是

Integer

参数解释:

待取消关联的目标工作项ID。

约束限制:

必须与源工作项已存在关联关系;不存在则返回错误码DEV_21_400806。

取值范围:

不涉及。

默认取值:

不涉及。

响应参数

状态码:200

表3 响应Body参数

参数

参数类型

描述

result

result object

参数解释:

被取消的关联关系记录详情,包含关联关系的所有属性信息。

status

String

参数解释:

接口整体响应状态。

取值范围:

  • success:取消关联工作项成功。

  • error:取消关联工作项失败,详见错误码说明。

表4 result

参数

参数类型

描述

identifier

String

参数解释:

关联关系唯一标识。

取值范围:

32个字符,由小写字母和数字组成。

issueId

Integer

参数解释:

源工作项ID。

取值范围:

不涉及。

projectId

Integer

参数解释:

源项目数字ID。

取值范围:

不涉及。

associateType

String

参数解释:

关联类型。

取值范围:

  • associate:关联工作项。

associateIssueId

Integer

参数解释:

被关联工作项ID。

取值范围:

不涉及。

associateProjectId

Integer

参数解释:

被关联项目数字ID。

取值范围:

不涉及。

createdOn

String

参数解释:

关联关系创建时间。

取值范围:

格式为yyyy-MM-dd HH:mm:ss。

authorId

Integer

参数解释:

创建该关联关系的用户ID。

取值范围:

不涉及。

flag

Boolean

参数解释:

关联关系有效标识。

取值范围:

  • true:关联有效。

  • false:关联已失效。

状态码:400

表5 响应Body参数

参数

参数类型

描述

{自定义key}

Map<String,ErrorRsp>

失败时返回的错误对象

表6 ErrorRsp

参数

参数类型

描述

error_code

String

错误码

error_msg

String

错误描述

请求示例

在项目ID45fba8eff9f3492585ce846767028f73中ID为71058791的工作项取消关联同项目中的另一个工作项71058792

POST https://{endpoint}/v2/issues/cancel-associate

{
  "projectUUId" : "45fba8eff9f3492585ce846767028f73",
  "attachProjectUUId" : "45fba8eff9f3492585ce846767028f73",
  "issueId" : 71058791,
  "attachIssueId" : 71058792
}

响应示例

状态码:200

{
  "result" : {
    "identifier" : "27bdd22a0eeb4eefa431bebd2940b082",
    "issueId" : 71058791,
    "projectId" : 13628638,
    "associateType" : "associate",
    "associateIssueId" : 71058792,
    "associateProjectId" : 13628638,
    "createdOn" : "2026-09-01 20:37:39",
    "authorId" : 1274137,
    "flag" : true
  },
  "status" : "success"
}

状态码:400

{
  "error" : {
    "code" : "DEV_21_400806",
    "reason" : "工作项关联关系不存在"
  },
  "status" : "error"
}

SDK代码示例

SDK代码示例如下。

Java

在项目ID45fba8eff9f3492585ce846767028f73中ID为71058791的工作项取消关联同项目中的另一个工作项71058792

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.projectman.v4.region.ProjectManRegion;
import com.huaweicloud.sdk.projectman.v4.*;
import com.huaweicloud.sdk.projectman.v4.model.*;


public class CancelScrumAssociateSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");

        ICredential auth = new BasicCredentials()
                .withAk(ak)
                .withSk(sk);

        ProjectManClient client = ProjectManClient.newBuilder()
                .withCredential(auth)
                .withRegion(ProjectManRegion.valueOf("<YOUR REGION>"))
                .build();
        CancelScrumAssociateRequest request = new CancelScrumAssociateRequest();
        CancelAssociateIssueRequest body = new CancelAssociateIssueRequest();
        body.withAttachIssueId(71058792);
        body.withIssueId(71058791);
        body.withAttachProjectUUId("45fba8eff9f3492585ce846767028f73");
        body.withProjectUUId("45fba8eff9f3492585ce846767028f73");
        request.withBody(body);
        try {
            CancelScrumAssociateResponse response = client.cancelScrumAssociate(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}

Python

在项目ID45fba8eff9f3492585ce846767028f73中ID为71058791的工作项取消关联同项目中的另一个工作项71058792

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkprojectman.v4.region.projectman_region import ProjectManRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkprojectman.v4 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]

    credentials = BasicCredentials(ak, sk)

    client = ProjectManClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(ProjectManRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = CancelScrumAssociateRequest()
        request.body = CancelAssociateIssueRequest(
            attach_issue_id=71058792,
            issue_id=71058791,
            attach_project_uu_id="45fba8eff9f3492585ce846767028f73",
            project_uu_id="45fba8eff9f3492585ce846767028f73"
        )
        response = client.cancel_scrum_associate(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Go

在项目ID45fba8eff9f3492585ce846767028f73中ID为71058791的工作项取消关联同项目中的另一个工作项71058792

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    projectman "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/projectman/v4"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/projectman/v4/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/projectman/v4/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")

    auth, err := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        SafeBuild()

    if err != nil {
        fmt.Println(err)
        return
    }

    hcClient, err := projectman.ProjectManClientBuilder().
         WithRegion(region.ValueOf("<YOUR REGION>")).
         WithCredential(auth).
         SafeBuild()


    if err != nil {
        fmt.Println(err)
        return
    }

    client := projectman.NewProjectManClient(hcClient)

    request := &model.CancelScrumAssociateRequest{}
	attachProjectUUIdCancelAssociateIssueRequest:= "45fba8eff9f3492585ce846767028f73"
	request.Body = &model.CancelAssociateIssueRequest{
		AttachIssueId: int32(71058792),
		IssueId: int32(71058791),
		AttachProjectUUId: &attachProjectUUIdCancelAssociateIssueRequest,
		ProjectUUId: "45fba8eff9f3492585ce846767028f73",
	}
	response, err := client.CancelScrumAssociate(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

200

取消关联成功

400

项目、工作项或关联关系不存在

错误码

请参见错误码。

相关文档