Search code examples
javarestalmhp-quality-centerdefects

Updating QC ALM defect Comments Section using REST API


Using REST API in Java I am trying to update QC ALM. I am getting value in html format when I am trying to extract comment section for any Defect. So, if I want to add any comment, do I need to pass as HTML content with the previous comment or is there any other way?

I have tried by Just passing the comment but it removes all the previous comment and it does not show the person name who is updating the comment as it happens through GUI.


Solution

  • This would help someone who is new to HP REST API.
    1. To find available API end-points,

    GET /qcbin/rest/resouce-list

    1. To get Users' full name

      GET /qcbin/rest/domains/<domain_name>/projects/<project>/customization/users/<user_name>

    2. To get defect comment, the below request fetches only Defect ID = 1 and outputs dev-comments field.

      GET /qcbin/rest/domains/<domain_name>/projects/<project_name>/defects?query={id[1]}&fields=dev-comments

    3. Sample JSON payload,

      PUT /qcbin/rest/domains/<domain_name>/projects/<project>/defects/1

    {

    "Fields": [{
        "Name": "dev-comments",
        "values": [{
            "value": "<html><body><span style=\"font-size:14px\">USER FULL NAME &lt;USER_ID&gt;, 2016-06-29:</span></font></b>\n<font color=\"#767676\" style=\"font-family:'hpsimplified-regular' , sans-serif\"><span style=\"font-size:14px\"> </span></font>Comment 1 \n</div> \n</body></html>"
        },
        {
            "value": "<html><body><span style=\"font-size:14px\">USER FULL NAME &lt;USER_ID&gt;, 2016-06-29:</span></font></b>\n<font color=\"#767676\" style=\"font-family:'hpsimplified-regular' , sans-serif\"><span style=\"font-size:14px\"> </span></font>Comment 2 \n</div> \n</body></html>"
        }]
    }]
    

    }