Help Center/ CodeArts Req/ API Reference/ Application Examples/ Example 3: Querying Comments on Work Items of a User
Updated on 2023-06-12 GMT+08:00

Example 3: Querying Comments on Work Items of a User

Scenario

The test001 user has created or participated in a CodeArts Req project. The project contains created work items.

For details about how to call APIs, see Calling APIs.

Constraints

Ensure that work items are available.

Involved API

Query the work item list of a specified project based on the user token, and then query work item comments based on the project ID and work item ID. The procedure is as follows:

  1. Step 1: Query the work item list of the user
  2. Step 2: Query comments on work items.

Step 1: Query the work item list of the user

  • API information

    URI: Post /v4/projects/{project_id}/issues

    For details about the API document, see "Using Advanced Query to Find Work Items."

    For details about online API Explorer debugging, see "Advanced Query to Find Work Items."

      

  • Request example
    Post  https://projectman-ext.ap-southeast-3.myhuaweicloud.com/v4/projects/526cefde62004de2b62b5e8dd2c2b3af/issues
  • Request body
    {
    "status_ids": [1],
    "limit":1
    }

      

  • Response example
    {
    "issues": [
            {
    "id": 1692040,
    "name":"Test",
    "done_ratio": 0,
    "tracker": {
    "id": 2,
    "name": "Task"
                },
    "priority": {
    "id": 2,
    "name": "Medium"
                },
    "severity": {
    "id": 12,
    "name": "Minor"
                },
    "status": {
    "id": 1,
    "name": "New"
                },
    "updated_time": "2020-09-17 10:18:31",
    "begin_time": "1970-01-01",
    "end_time": "1970-01-01",
    "project": {
    "project_num_id": 3694732,
    "project_id": "526cefde62004de2b62b5e8dd2c2b3af",
    "project_name": "sdfsdfdsf"
                },
    "parent_issue": {
    "id": 1684959,
    "name": "testDemo Adassada"
                },
    "module": {
    "id": null,
    "name": null
                },
    "domain": {
    "id": null,
    "name": null
                },
    "iteration": {
    "id": null,
    "name": null
                },
    "expected_work_hours": 0.0,
    "actual_work_hours": 0.0,
    "created_time": "2020-09-17 10:18:31",
    "custom_fields": [],
    "assigned_cc_user": null,
    "assigned_user": {
    "id": 4091,
    "name": "test001",
    "nick_name": "pcedgeXXXXXXX"
                },
    "creator": {
    "id": 4091,
    "name": "test001",
    "nick_name": "pcedgeXXXXXXX"
                },
    "developer": {
    "id": 0,
    "name": null,
    "nick_name": null
                }
            }
        ],
    "total": 24
    }
    

Step 2: Query comments on work items

  • API information

    URI: GET /v4/projects/{project_id}/issues/{issue_id}/comments

    For details about the API document, see "Obtaining the Comment List of a Specified Work Item."

    For details about online API Explorer debugging, see "Obtaining the Comment List of a Specified Work Item."

  • Request example
    GET  https://projectman-ext.ap-southeast-3.myhuaweicloud.com/v4/projects/526cefde62004de2b62b5e8dd2c2b3af/issues/1692040/comments
  • Response example
     {
        "comments": [
            {
                "id": 3235092,
                "created_time": "2020-08-26",
                "user": {
                    "user_num_id": 4091,
                    "user_name": "test001",
                    "nick_name": "pcedgeXXXXXXX"
                },
                "comment": "<p>This is a test example.</p>"
            }
        ],
        "total": 1
    }