Adding comments using OSLC
![]()
Hi,
I am creating a workitem using OSLC 2.0. I want to add comment to the workitem,how to do it? Thanks in Advance! Sudipto |
Accepted answer
7 other answers
![]()
There is a dedicated section in the RTC OSLC API Wiki. Have a read.
https://jazz.net/wiki/bin/view/Main/WorkItemAPIsForOSLCCM20#Adding_comments
Comments Hi Donanld,
</rdf:Description> <rdf:Description rdf:about="https://localhost:9443/jazz/resource/itemOid/ com.ibm.team.workitem.WorkItem/_xoNikpHMEeC_rYSykUtXXA/rtc_cm:comments/oslc:comment/1"> <rdf:type rdf:resource="http://open-services.net/ns/core#Comment"/> <dcterms:created>2011-07-06T15:09:47.574Z</dcterms:created> <dcterms:creator rdf:resource="https://localhost:9443/jazz/oslc/users/_KGRY4CFWEdq-WY5y7lROQw"/> <dcterms:description rdf:parseType="Literal">Another Comment</dcterms:description> <dcterms:identifier>__Qo2YKfhEeCBC4EUCjDhXA</dcterms:identifier> <oslc:discussion rdf:resource="https://localhost:9443/jazz/resource/itemOid/ com.ibm.team.workitem.WorkItem/_xoNikpHMEeC_rYSykUtXXA/rtc_cm:comments"/> </rdf:Description> 1
If you mean that you want to add the comment at the same time as creating the work item, I don't think you can. I believe you will need to create the work item first, get the reference, and then add the comment(s). I'm currently facing the same issue. I would like to add a comment while creating a workitem over OSLC.
2
The web interface does not use OSLC API, so you cannot claim that it "should be capable of" doing what you want.
In my eyes, it is unnecessary overhead to send two HTTP requests where one would suffice. It's not obvious why comments cannot be created in the same request.
You can raise an enhancement request here:
showing 5 of 6
show 1 more comments
|
![]() I've been following the link that Donald Nong provide: https://jazz.net/wiki/bin/view/Main/WorkItemAPIsForOSLCCM20#Adding_comments
But I still get the "404 Bad Request" in following 2 attempts:
1. Use the url from work item I created:
I just appended "/oslc:comment" at the end according to the documentation.
2. Use the url from the documentation:
"https://[servername]/ccm/resource/itemOid/com.ibm.team.workitem.WorkItem/_xoNikpHMEeC_rYSykUtXXA/rtc_cm:comments/oslc:comment"
I'm using C# and create work item POST call worked.
What is the right url to do a POST request to create comments?
Thanks,
Bing
Comments Refer to my answer below, I have been successfully using that code for years Hi Lukas,
Thank you! I think I basically using the same way but in C# and got 404. See my answer below.
|
![]() Adding comments through the OSLC interface can be done like this:
|
![]() Hi Lucas,
My code sample seems too long for comments, so I had to put it as an answer. Sorry if I'm not using this correctly.
This is the url that I got from oslc:discussedBy: "https://[ServerName]/oslc/workitems/_q8RqoJoQEee2N-g-o1qd6A/rtc_cm:comments"
I also appended "/oslc:comment" at the end. This is my code. It works to create a workitem (json is the properties for the new wokitem), I'm using it for creating comments too but got 404.
|
![]() Is possible to set the creation date? I'm setting it, but its not having effect. Comment on work item is being created, but not setting the date I sent:
POST
BODY
{
"dcterms:description": "comment",
"dcterms:created": "2021-02-24T15:36:33.371Z"
}
|
![]() After many hours, I finally looked at the ccm.log file. The response was saying my account did not have the required group memberships. The ccm.log clarified that my account did have the necessary group memberships, but that the request was blocked because it might have been malicious and said I had to use the JSESSION ID in a CRSF Prevent header. My tool was not retrieving any such JSESSIONID in the header, so I found you could get around the check by specifying User-Agent. HERE is how I got it to work in 7.0.2:
POST:
https://EWMHost:port/ccm/oslc/workitems/12345/rtc_cm:comments/oslc:comment
Headers:
Accept: application/json
Content-Type: application/json
OSLC-Core-Version: 2.0
User-Agent: CustomInterface
Request Body:
{"dcterms:description":"My Comment"}
|