1

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.

rohit saraf
  • 37
  • 1
  • 8
  • What function are you using to add the comment? – Husain Khambaty Jun 29 '16 at 12:39
  • 1. Yes, you gotta pass the previous comment when making a PUT request. 2. API works in a different way than GUI, before sending the comments get the user full name and send that info along with the defects comment. – Barney Jun 30 '16 at 15:00
  • @echkaay I am using update method and passing entity name as dev-comment and since entity value is in html format so I am putting whole data in CDATA to pass. – rohit saraf Jul 01 '16 at 06:44
  • @Barney how can I get the full name from QC and can you tell me how to update "assigned to UUID " as when I am passing any id I am getting exception that user id is not validated – rohit saraf Jul 01 '16 at 06:47

1 Answers1

0

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>"
    }]
}]

}

Barney
  • 1,851
  • 2
  • 19
  • 36