Associating a Work Item
Function
This API is used to associate a work item with one or more target work items, while also supporting the cancellation of existing associations in the same request.
After the association is established, a journal record is generated. The association is also subject to the maximum number of associations per work item.
Calling Method
For details, see Calling APIs.
Authorization Information
No identity policy-based permission required for calling this API.
URI
POST /v2/issues/associate-issue
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| X-Auth-Token | Yes | String | Definition User access credential. It can be obtained by calling the IAM API to obtain a user token (the value of X-Subject-Token in the response header). Constraints N/A Range 10 to 32,768 characters. Default Value N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| projectUUId | Yes | String | Definition Source project UUID, identifying the project to which the source work item for association belongs. Constraints 32-character UUID string. This parameter is mandatory. Range 32 characters, consisting of lowercase letters and digits. Default Value N/A |
| attachProjectUUId | No | String | Definition Target project UUID, identifying the project to which the target work item for association belongs. This parameter is mandatory for cross-project association and optional for intra-project association. Constraints 32-character UUID string. If the value is different from projectUUId, it is considered a cross-project association. Range 32 characters, consisting of lowercase letters and digits. Default Value N/A |
| issueId | Yes | Integer | Definition Source work item ID. That is, the unique ID of the work item for which the association is to be established. Constraints The work item must exist and must not be archived. Range N/A Default Value N/A |
| associatedIssueIdList | No | Array of strings | Definition ID list of work items to be associated. This is the set of target work item IDs for which new associations need to be established. Constraints Each element is a work item ID in string format (automatically converted to an integer by the server). It cannot include the issue ID itself. The total number of associations per work item is limited by the system upper limit. Range N/A Default Value N/A |
| unassociatedIssueIdList | No | Array of strings | Definition ID list of work items to be disassociated. This is the set of target work item IDs for which associations need to be removed. Can be mixed in the same request to support association relationship adjustments. Constraints Each element is a work item ID in string format. Only existing association relationships are processed. Range N/A Default Value N/A |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| result | Array of AssociateIssueDetail objects | Definition List of newly added association records, where each element corresponds to an association. |
| status | String | Definition Overall response status of the API. Range |
| Parameter | Type | Description |
|---|---|---|
| identifier | String | Definition Association ID. Range 32 characters, consisting of lowercase letters and digits. |
| issueId | Integer | Definition Source work item ID. Range N/A |
| projectId | Integer | Definition Source project numeric ID (primary key of the project table). Range N/A |
| associateType | String | Definition Association type. Range |
| associateIssueId | Integer | Definition ID of the associated work item. Range N/A |
| associateProjectId | Integer | Definition Numeric ID of the associated project (primary key of the project table). Range N/A |
| createdOn | String | Definition Association creation time. Range The format is yyyy-MM-dd HH:mm:ss. |
| authorId | Integer | Definition ID of the user who created the association. Range N/A |
| flag | Boolean | Definition Association validity flag. Range |
| region | String | Definition Region ID, indicating the region where the association is located. Range N/A |
Status code: 400
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Error code. |
| error_msg | String | Error message. |
Example Requests
Example request for associating a work item.
POST https://{endpoint}/v2/issues/associate-issue
{
"projectUUId" : "45fba8eff9f3492585ce846767028f73",
"attachProjectUUId" : "45fba8eff9f3492585ce846767028f73",
"issueId" : 71058791,
"associatedIssueIdList" : [ "71058792" ],
"unassociatedIssueIdList" : [ ]
} Example Responses
Status code: 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"
} Status code: 400
{
"error" : {
"code" : "DEV_21_400806",
"reason" : "The work item association does not exist."
},
"status" : "error"
} SDK Sample Code
The SDK sample code is as follows.
Java
Example request for associating a work item.
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
Example request for associating a work item.
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
Example request for associating a work item.
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) } } |
More
For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.
Status Codes
| Status Code | Description |
|---|---|
| 200 | The association is successful. |
| 400 | The work item association does not exist. |
Error Codes
See Error Codes.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot