关联工作项 - AssociateScrumIssue
功能介绍
将一个工作项与一个或多个目标工作项建立关联关系,同时支持在同一次请求中取消已有关联。
关联关系建立后会同步生成 journal 动态记录,并受单工作项关联数量上限约束。
调用方法
请参见如何调用API。
授权信息
当前API调用无需身份策略权限。
URI
POST /v2/issues/associate-issue
请求参数
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| X-Auth-Token | 是 | String | 参数解释: 用户访问凭证。通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 约束限制: 不涉及。 取值范围: 长度为10~32768个字符。 默认取值: 不涉及。 |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| projectUUId | 是 | String | 参数解释: 源项目UUID。标识执行关联操作的源工作项所属项目。 约束限制: 32位UUID字符串,必填字段。 取值范围: 32个字符,由小写字母和数字组成。 默认取值: 不涉及。 |
| attachProjectUUId | 否 | String | 参数解释: 目标项目UUID。标识待关联工作项所属的项目;跨项目关联时必填,同项目关联时可省略。 约束限制: 32位UUID字符串;若与projectUUId不同则视为跨项目关联。 取值范围: 32个字符,由小写字母和数字组成。 默认取值: 不涉及。 |
| issueId | 是 | Integer | 参数解释: 源工作项ID。即需要建立关联关系的工作项唯一ID。 约束限制: 工作项必须存在且未被归档。 取值范围: 不涉及。 默认取值: 不涉及。 |
| associatedIssueIdList | 否 | Array of strings | 参数解释: 待关联工作项ID列表。本次操作需要新增关联关系的目标工作项ID集合。 约束限制: 每个元素为字符串形式的工作项ID(服务端自动转换为整数);不能包含issueId自身;单工作项关联总数受系统上限约束。 取值范围: 不涉及。 默认取值: 不涉及。 |
| unassociatedIssueIdList | 否 | Array of strings | 参数解释: 待取消关联工作项ID列表。本次操作需要解除关联关系的目标工作项ID集合;可在同一次请求中混合使用以支持关联关系调整。 约束限制: 每个元素为字符串形式的工作项ID;仅处理已存在的关联关系。 取值范围: 不涉及。 默认取值: 不涉及。 |
响应参数
状态码:200
| 参数 | 参数类型 | 描述 |
|---|---|---|
| result | Array of AssociateIssueDetail objects | 参数解释: 本次新增的关联关系记录列表,每个元素对应一条关联关系。 |
| status | String | 参数解释: 接口整体响应状态。 取值范围: |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| identifier | String | 参数解释: 关联关系唯一标识。 取值范围: 32个字符,由小写字母和数字组成。 |
| issueId | Integer | 参数解释: 源工作项ID。 取值范围: 不涉及。 |
| projectId | Integer | 参数解释: 源项目数字ID(项目表主键)。 取值范围: 不涉及。 |
| associateType | String | 参数解释: 关联类型。 取值范围: |
| associateIssueId | Integer | 参数解释: 被关联工作项ID。 取值范围: 不涉及。 |
| associateProjectId | Integer | 参数解释: 被关联项目数字ID(项目表主键)。 取值范围: 不涉及。 |
| createdOn | String | 参数解释: 关联关系创建时间。 取值范围: 格式为yyyy-MM-dd HH:mm:ss。 |
| authorId | Integer | 参数解释: 创建该关联关系的用户ID。 取值范围: 不涉及。 |
| flag | Boolean | 参数解释: 关联关系有效标识。 取值范围: |
| region | String | 参数解释: 区域标识,标识该关联关系所在的局点。 取值范围: 不涉及。 |
状态码:400
| 参数 | 参数类型 | 描述 |
|---|---|---|
| error_code | String | 错误码 |
| error_msg | String | 错误描述 |
请求示例
关联工作项请求示例
POST https://{endpoint}/v2/issues/associate-issue
{
"projectUUId" : "45fba8eff9f3492585ce846767028f73",
"attachProjectUUId" : "45fba8eff9f3492585ce846767028f73",
"issueId" : 71058791,
"associatedIssueIdList" : [ "71058792" ],
"unassociatedIssueIdList" : [ ]
} 响应示例
状态码: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,
"region" : "cn-north-4"
} ],
"status" : "success"
} 状态码:400
{
"error" : {
"code" : "DEV_21_400806",
"reason" : "工作项关联关系不存在"
},
"status" : "error"
} SDK代码示例
SDK代码示例如下。
Java
关联工作项请求示例
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 55 | 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.*; import java.util.List; import java.util.ArrayList; public class AssociateScrumIssueSolution { 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(); AssociateScrumIssueRequest request = new AssociateScrumIssueRequest(); AssociateIssueRequest body = new AssociateIssueRequest(); List<String> listbodyAssociatedIssueIdList = new ArrayList<>(); listbodyAssociatedIssueIdList.add("71058792"); body.withAssociatedIssueIdList(listbodyAssociatedIssueIdList); body.withIssueId(71058791); body.withAttachProjectUUId("45fba8eff9f3492585ce846767028f73"); body.withProjectUUId("45fba8eff9f3492585ce846767028f73"); request.withBody(body); try { AssociateScrumIssueResponse response = client.associateScrumIssue(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
关联工作项请求示例
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 | # 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 = AssociateScrumIssueRequest() listAssociatedIssueIdListbody = [ "71058792" ] request.body = AssociateIssueRequest( associated_issue_id_list=listAssociatedIssueIdListbody, issue_id=71058791, attach_project_uu_id="45fba8eff9f3492585ce846767028f73", project_uu_id="45fba8eff9f3492585ce846767028f73" ) response = client.associate_scrum_issue(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
关联工作项请求示例
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 55 56 57 | 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.AssociateScrumIssueRequest{} var listAssociatedIssueIdListbody = []string{ "71058792", } attachProjectUUIdAssociateIssueRequest:= "45fba8eff9f3492585ce846767028f73" request.Body = &model.AssociateIssueRequest{ AssociatedIssueIdList: &listAssociatedIssueIdListbody, IssueId: int32(71058791), AttachProjectUUId: &attachProjectUUIdAssociateIssueRequest, ProjectUUId: "45fba8eff9f3492585ce846767028f73", } response, err := client.AssociateScrumIssue(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
| 状态码 | 描述 |
|---|---|
| 200 | 关联成功 |
| 400 | 工作项关联关系不存在 |
错误码
请参见错误码。