Updated on 2026-10-27 GMT+08:00

Creating a Work Item Comment

Function

This API is used to create a new comment or reply to a comment for a specified work item. Set category to comment when creating a new comment. Set category to reply and specify parent_id and root_id when replying to an existing comment. Mentioned users will be notified.

Calling Method

For details, see Calling APIs.

Authorization Information

No identity policy-based permission required for calling this API.

URI

POST /v1/ipdprojectservice/projects/{project_id}/issues/{issue_id}/comments

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

32-character ID of a project, which must be unique. Obtain the value by calling the API for querying the IPD project list. The value of id in the response message body is the project ID.

Constraints

N/A

Range

A string of 32 characters consisting of letters and digits.

Default Value

N/A

issue_id

Yes

String

Definition

Unique ID of a work item. You can obtain the value from the Querying Work Items or Querying Tree-shaped Work Items API. The value is id in the response body.

Constraints

N/A

Range

A string of 18 to 19 digits.

Default Value

N/A

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

category

No

String

Definition

Comment type, which distinguishes between new comments and reply comments. System operation type comments cannot be created through this API.

Constraints

N/A

Range

  • comment: New text comment.

  • reply: Reply to other comment.

  • operation: System operation (cannot be created through this API).

Default Value

N/A

issue_category

No

String

Definition

Type of the work item to which the comment belongs, such as IR, SR, and AR. This field identifies the work item type of the comment and determines the business logic for comment display and notification.

Constraints

N/A

Range

IPD work item types, such as IR, SR, AR, RR, US, Task, and Bug.

Default Value

N/A

description

No

String

Definition

Comment content, described in HTML markup language with support for rich text (including text, @mentions, images, and other elements).

Constraints

1 to 10,000 characters.

Range

N/A

Default Value

N/A

parent_id

No

String

Definition

Parent ID of the comment, which is the ID of the comment being replied to.

Constraints

This parameter is mandatory when replying to a comment.

Range

A numeric string of 18 to 19 characters.

Default Value

N/A

root_id

No

String

Definition

Root ID of the comment, which is the ID of the top-level comment being replied to, used to build the nested comment thread hierarchy.

Constraints

This parameter is mandatory when replying to a comment and cannot be set when creating a comment.

Range

A numeric string of 18 to 19 characters.

Default Value

N/A

at_others

No

String

Definition

List of user IDs @mentioned in the comment, separated by commas (,). After this parameter is specified, the system notifies the mentioned users. The notification mode can be configured in Req > Settings > Work Item > Notifications.

Constraints

Each user ID contains 32 characters.

Range

N/A

Default Value

N/A

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

status

String

Definition

Response status of the comment operation, used to indicate whether the API call is successful.

Range

  • success: The comment operation is successful.

  • error: The comment operation fails.

message

String

Definition

Response message of the comment operation. The error message is returned when an API call fails.

result

CommentEntity object

Definition

Comment operation result, including the comment ID, content, creator, creation time, and other complete comment attributes. When deleting a comment, only key fields such as the comment ID, pin status, and last modifier are returned.

Table 4 CommentEntity

Parameter

Type

Description

id

String

Definition

Comment ID, which uniquely identifies a comment.

Range

A numeric string of 18 to 19 characters.

category

String

Definition

Comment type, which distinguishes between user-created comments, reply comments, and system-generated key operation comments.

Range

  • comment: Text comment created by a user.

  • reply: Comment replying to another user.

  • operation: Comment auto-generated by the system based on key operations, such as status transitions and field changes.

type

String

Definition

Comment metadata type, used by the frontend to distinguish the rendering format of comments.

Range

Fixed at comment.

top

Boolean

Definition

Whether to display the comment in the pinned area.

Range

  • true: Displayed in the pinned area.

  • false: Not displayed in the pinned area.

top_time

String

Definition

Unix timestamp of the pin time, in milliseconds. When there are multiple pinned comments, the most recently pinned comment is displayed at the top.

Range

A numeric string of 10 to 19 characters.

description

String

Definition

Comment content, described using HTML tags with support for rich text (including text, @mentions, images, and other elements).

Range

1 to 10,000 characters.

issue_id

String

Definition

ID of the work item to which the comment belongs. It can be obtained by calling the Querying the Work Item List API. The value of the id field in the response body is the work item ID.

Range

A numeric string of 18 to 19 characters.

top_flag

Boolean

Definition

Whether the current comment is pinned.

Range

  • true: Pinned.

  • false: Not pinned.

created_by

String

Definition

Comment creator ID.

Range

32 characters.

modified_by

String

Definition

Last modifier ID of the comment.

Range

32 characters.

created_date

String

Definition

Unix timestamp of the comment creation time, in milliseconds.

Range

A numeric string of 10 to 19 characters.

modified_date

String

Definition

Unix timestamp of the last modification time of the comment, in milliseconds.

Range

A numeric string of 10 to 19 characters.

creator_info

UserVO object

Definition

Detailed information of the comment creator, including the user ID, username, nickname, tenant ID, role, and other attributes.

extend_attribute

String

Definition

Extended attributes of the comment, expressed as a JSON string, mainly used to describe the operation information associated with system-generated comments (such as status transitions and field changes). Only system comments (category: operation) have this value.

Range

0 to 10,000 characters.

extend_attribute_obj

CommentExtendAttribute object

Definition

Extended attribute object of the comment, containing structured information such as the operator, operation action, and values before and after status transitions. Only system comments (category: operation) have this value.

extend_attribute_objs

Array of CommentExtendAttribute objects

Definition

Array of extended attribute objects for comments, containing structured information for multiple extended operations. Only system comments (category: operation) have this value.

Table 5 CommentExtendAttribute

Parameter

Type

Description

operator

UserVO object

Definition

Operator user information, including the user ID, username, tenant ID, role, and other attributes.

operator_id

String

Definition

Operator ID.

Range

32 characters.

action

String

Definition

Chinese description of the action performed when the system generates a comment, such as saving the initial requirement or modifying the status.

Range

N/A

action_us

String

Definition

English description of the action performed when the system generates a comment, with the same meaning as the action field, used for internationalization scenarios.

Range

N/A

object_type

String

Definition

Object type corresponding to the system-generated comment, used to identify the dimension of the object affected by this operation, such as the status field or owner field.

Range

N/A

pre_status_code

String

Definition

Status code of the work item before transition, used to identify the previous status of the work item before this operation.

Range

N/A

new_status_code

String

Definition

Status code of the work item after transition, used to identify the latest status of the work item after this operation.

Range

N/A

pre_status

Object

Definition

Field value of the work item before transition. The object type varies depending on the field_type_id value.

  • 10001: StatusVO object.

  • 10007, 10008: String.

  • 10003, 10004: Date and time.

  • 10005, 10006: Number.

new_status

Object

Definition

Field value of the work item after transition. The object type varies depending on the field_type_id value.

  • 10001, 10002: StatusVO object.

  • 10007, 10008: String.

  • 10003, 10004: Date and time.

  • 10005, 10006: Number.

  • 10009, 10010: UserVO object.

field_type

String

Definition

Field type enumeration value, used together with field_type_id to identify the field type affected by this operation, such as STATUS.

Range

N/A

field_type_id

String

Definition

ID corresponding to the field type, used together with field_type. For common values and corresponding field value types, see the pre_status/new_status field description.

Range

N/A

display_name

String

Definition

Field display name, used to identify the name of the field affected by this operation in the UI, such as status and owner.

Range

N/A

Table 6 UserVO

Parameter

Type

Description

user_id

String

Definition

User ID.

Range

N/A

user_num_id

Integer

Definition

Short ID of a user.

Range

N/A

user_name

String

Definition

Username.

Range

N/A

domain_id

String

Definition

ID of the domain to which the user belongs.

Range

N/A

domain_name

String

Definition

Tenant name.

Range

N/A

nick_name

String

Definition

User alias.

Range

N/A

role_id

String

Definition

Role ID. If a user has multiple roles in a project, use commas (,) to separate the values.

Range

N/A

role_name

String

Definition

Role name. If a user has multiple roles, use commas (,) to separate the values.

Range

N/A

role_code

String

Definition

Role code. If a user has multiple roles, use commas (,) to separate the values.

Range

N/A

Status code: 400

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Definition

Error code.

Range

N/A

error_msg

String

Definition

Error description, which is a supplement to error_code.

Range

N/A

Example Requests

  • Reply to comment 1223642621183123456 under IR work item 1223642181313880065 in project 99719a734aee4f20aae8c8e3bbd4e365. The comment content includes @mention of user c2d89e38a64a466f8f945f595df4402d.

    POST https://{endpoint}/v1/ipdprojectservice/projects/99719a734aee4f20aae8c8e3bbd4e365/issues/1223642181313880065/comments
    
    {
      "category" : "reply",
      "issue_category" : "IR",
      "description" : "<p><span class=\"ql-mention-link\" data-mention-id=\"ForTest\" title=\"ForTest\" mentionchar=\"@\"><span contenteditable=\"false\">@ForTest</span></span>&nbsp;Could you please check?</p>",
      "parent_id" : "1223642621183123456",
      "root_id" : "1223642621183123456",
      "at" : "c2d89e38a64a466f8f945f595df4402d",
      "at_others" : "c2d89e38a64a466f8f945f595df4402d"
    }
  • Create a text comment under IR work item 1223642181313880065 in project 99719a734aee4f20aae8c8e3bbd4e365.

    POST http://{{endpoint}}/v1/ipdprojectservice/projects/99719a734aee4f20aae8c8e3bbd4e365/issues/1223642181313880065/comments
    
    {
      "category" : "comment",
      "issue_category" : "IR",
      "description" : "<p>Create a comment.</p>"
    }

Example Responses

Status code: 200

{
  "status" : "success",
  "message" : "",
  "result" : {
    "id" : "1223666764846850049",
    "category" : "Comment",
    "type" : "comment",
    "top" : false,
    "description" : "<p>Create a system comment.</p>",
    "at" : "",
    "issue_id" : "1223642181313880065",
    "top_flag" : false,
    "created_by" : "c2d89e38a64a466f8f945f595df4402d",
    "created_date" : "1769674491368",
    "creator_info" : {
      "user_id" : "c2d89e38a64a466f8f945f595df4402d",
      "user_num_id" : null,
      "user_name" : "ForTest",
      "domain_id" : "aae03ca0d6814951980945b6eeca56cd",
      "domain_name" : null,
      "nick_name" : "ForTest",
      "role_id" : "5c78db505ee3486bb91840023c8e6d6c,d40d48b766d74ad680be222c128498c9",
      "role_name" : "Project manager, project administrator.",
      "role_code" : "Project manager,project_admin"
    }
  }
}

Status code: 400

{
  "error_code" : "PM.02174103",
  "error_msg" : "No permission."
}

SDK Sample Code

The SDK sample code is as follows.

Java

  • Reply to comment 1223642621183123456 under IR work item 1223642181313880065 in project 99719a734aee4f20aae8c8e3bbd4e365. The comment content includes @mention of user c2d89e38a64a466f8f945f595df4402d.

     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.*;
    
    
    public class CreateIpdIssueCommentsSolution {
    
        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();
            CreateIpdIssueCommentsRequest request = new CreateIpdIssueCommentsRequest();
            request.withProjectId("{project_id}");
            request.withIssueId("{issue_id}");
            CommentCreateVO body = new CommentCreateVO();
            body.withAt("c2d89e38a64a466f8f945f595df4402d");
            body.withRootId("1223642621183123456");
            body.withParentId("1223642621183123456");
            body.withDescription("<p><span class="ql-mention-link" data-mention-id="ForTest" title="ForTest" mentionchar="@"><span contenteditable="false">@ForTest</span></span>&nbsp;Could you please check?</p>");
            body.withIssueCategory("IR");
            body.withCategory(CommentCreateVO.CommentCreateVO.fromValue("reply"));
            request.withBody(body);
            try {
                CreateIpdIssueCommentsResponse response = client.createIpdIssueComments(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());
            }
        }
    }
    
  • Create a text comment under IR work item 1223642181313880065 in project 99719a734aee4f20aae8c8e3bbd4e365.

     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
    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 CreateIpdIssueCommentsSolution {
    
        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();
            CreateIpdIssueCommentsRequest request = new CreateIpdIssueCommentsRequest();
            request.withProjectId("{project_id}");
            request.withIssueId("{issue_id}");
            CommentCreateVO body = new CommentCreateVO();
            body.withDescription("<p>Create a comment.</p>");
            body.withIssueCategory("IR");
            body.withCategory(CommentCreateVO.CommentCreateVO.fromValue("comment"));
            request.withBody(body);
            try {
                CreateIpdIssueCommentsResponse response = client.createIpdIssueComments(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

  • Reply to comment 1223642621183123456 under IR work item 1223642181313880065 in project 99719a734aee4f20aae8c8e3bbd4e365. The comment content includes @mention of user c2d89e38a64a466f8f945f595df4402d.

     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
    # 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 = CreateIpdIssueCommentsRequest()
            request.project_id = "{project_id}"
            request.issue_id = "{issue_id}"
            request.body = CommentCreateVO(
                at="c2d89e38a64a466f8f945f595df4402d",
                root_id="1223642621183123456",
                parent_id="1223642621183123456",
                description="<p><span class="ql-mention-link" data-mention-id="ForTest" title="ForTest" mentionchar="@"><span contenteditable="false">@ForTest</span></span>&nbsp;Could you please check?</p>",
                issue_category="IR",
                category="reply"
            )
            response = client.create_ipd_issue_comments(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • Create a text comment under IR work item 1223642181313880065 in project 99719a734aee4f20aae8c8e3bbd4e365.

     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
    # 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 = CreateIpdIssueCommentsRequest()
            request.project_id = "{project_id}"
            request.issue_id = "{issue_id}"
            request.body = CommentCreateVO(
                description="<p>Create a comment.</p>",
                issue_category="IR",
                category="comment"
            )
            response = client.create_ipd_issue_comments(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

  • Reply to comment 1223642621183123456 under IR work item 1223642181313880065 in project 99719a734aee4f20aae8c8e3bbd4e365. The comment content includes @mention of user c2d89e38a64a466f8f945f595df4402d.

     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
    58
    59
    60
    61
    62
    63
    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.CreateIpdIssueCommentsRequest{}
    	request.ProjectId = "{project_id}"
    	request.IssueId = "{issue_id}"
    	atCommentCreateVo:= "c2d89e38a64a466f8f945f595df4402d"
    	rootIdCommentCreateVo:= "1223642621183123456"
    	parentIdCommentCreateVo:= "1223642621183123456"
    	descriptionCommentCreateVo:= "<p><span class="ql-mention-link" data-mention-id="ForTest" title="ForTest" mentionchar="@"><span contenteditable="false">@ForTest</span></span>&nbsp;Could you please check?</p>"
    	issueCategoryCommentCreateVo:= "IR"
    	categoryCommentCreateVo:= model.GetCommentCreateVoCategoryEnum().REPLY
    	request.Body = &model.CommentCreateVo{
    		At: &atCommentCreateVo,
    		RootId: &rootIdCommentCreateVo,
    		ParentId: &parentIdCommentCreateVo,
    		Description: &descriptionCommentCreateVo,
    		IssueCategory: &issueCategoryCommentCreateVo,
    		Category: &categoryCommentCreateVo,
    	}
    	response, err := client.CreateIpdIssueComments(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • Create a text comment under IR work item 1223642181313880065 in project 99719a734aee4f20aae8c8e3bbd4e365.

     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.CreateIpdIssueCommentsRequest{}
    	request.ProjectId = "{project_id}"
    	request.IssueId = "{issue_id}"
    	descriptionCommentCreateVo:= "<p>Create a comment.</p>"
    	issueCategoryCommentCreateVo:= "IR"
    	categoryCommentCreateVo:= model.GetCommentCreateVoCategoryEnum().COMMENT
    	request.Body = &model.CommentCreateVo{
    		Description: &descriptionCommentCreateVo,
    		IssueCategory: &issueCategoryCommentCreateVo,
    		Category: &categoryCommentCreateVo,
    	}
    	response, err := client.CreateIpdIssueComments(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

Response for a successful creation.

400

Response upon a request failure. For example, the user does not have the operation permission or the project does not exist.

Error Codes

See Error Codes.