Creating Draft Work Item returns 500
Hello,
I am trying to create a draft work item using JSON. I am passing the following information to the url
{
"title":"A test defect",
"rtc_cm:type":
{
"rdf:resource":"https://jazz01.<domain>.com/ccm04\/oslc/types/_eZ3Z8KuOEeKo-JGDY--3wg\/defect"
}
}
However, I am getting the following error message back
{"prefixes":{"oslc":"http:\/\/open-services.net\/ns\/core#"},"oslc:message":"null argument:","oslc:statusCode":500}
Does anybody have any idea why it is returning that error? The url was taken from an existing Work Item.
7 answers
Hello Brian,
Donald is right - 500 means a server error that you should be able to find in the cmm log.
More on the topic:
https://jazz.net/wiki/bin/view/Main/WorkItemAPIsForOSLCCM20
and
https://jazz.net/library/article/1001#consuming_oslc_services
Hope it helps,
Eric
Hello Brian,
log shows:
-
org.eclipse.core.runtime.AssertionFailedException: null argument:
-
at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:85)
-
at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:73)
-
at com.ibm.team.workitem.common.internal.workflow.StateGroupRegistry.getStateGroup(StateGroupRegistry.java:
-
29)
which makes me believe we're missing rtc_cm:state here.
"rtc_cm:state": {
"rdf:resource": "https:\/\/rtc:9443\/ccm\/oslc\/workflows\/_FckdEKD8EeGCjPo2EBGANQ\/states\/com.ibm.team.workitem.taskWorkflow\/3",
"rdf:type": [
{
"rdf:resource": "http:\/\/jazz.net\/xmlns\/prod\/jazz\/rtc\/cm\/1.0\/Status"
}
]
},
Comments
Bryan,
I was about to give you this reference, but was stuck with something else.
Sorry.
This doc states:
Creating a draft works exactly the same as creating a regular work item, but is not susceptible to missing required attributes.
So I would not expect any error regarding missing attributes.
I need to test, possibly tomorrow if able
I believe this is a defect based on my testing. Here are the couple of points I would bring up.
1. The instanceShape of the work item type in question (Task in my case) states that only the title/summary is required, since only for this attribute the <oslc:occurs/> value is "Exactly-one" and all the others are "Zero-or-one" or "Zero-or-many".
2. Using the same POST content (I used the presentation of an existing work item less the identifier), I could submit a work item, but not a "draft" work item. Creating draft work items always fails with the same error as quoted in Eric's post above. It's a bit ironic since it should have been much easier to create a "draft" than a proper one.
BTW, I'm using CLM 4.0.5.
1. The instanceShape of the work item type in question (Task in my case) states that only the title/summary is required, since only for this attribute the <oslc:occurs/> value is "Exactly-one" and all the others are "Zero-or-one" or "Zero-or-many".
2. Using the same POST content (I used the presentation of an existing work item less the identifier), I could submit a work item, but not a "draft" work item. Creating draft work items always fails with the same error as quoted in Eric's post above. It's a bit ironic since it should have been much easier to create a "draft" than a proper one.
BTW, I'm using CLM 4.0.5.
Brian,
please open a new defect against Work Item comp,
add your code, steps, and part of the ccm log that shows the AssertionFailedException,
Please add a link to the work item in this thread.
Thanks,
Eric
I think all you need is a valid type, I found that on my server I could create defects with nothing more than that.
eg.
{
"dc:type":
{
"rdf:resource":"https:\/\/mycroft:9443\/ccm\/oslc\/types\/_bhBPQNVBEeOa4Jat-pHN6g\/defect"
}
}
I determined the type by fetching the workitems from my projects area and looking for the type I needed:
eg:
https://mycroft:9443/ccm/oslc/contexts/_bhBPQNVBEeOa4Jat-pHN6g/workitems
Comments
showing 5 of 7
show 2 more comments
This is so stupid. But I got it working.
The JSON needs to be just like in the original question, BUT the 'Location' property needs to be taken and modified.
For example, my response header has:
Location: https://<server>/ccm/resource/itemOid/com.ibm.team.workitem.WorkItem/_HL4hMIZmEeqfEekxQfni2w?draftId=_HL69cIZmEeqfEekxQfni2w
But if you go there, it opens the editor with the default work item type (virtually useless if it can't even get the type right).
However, if you take information like the draftID from the location, and build a URL like this, it works:
https://<server>/ccm/web/projects/<projectName>?draftId=_HL69cIZmEeqfEekxQfni2w#action=com.ibm.team.workitem.newWorkItem&draftId=_HL69cIZmEeqfEekxQfni2w&type=com.ibm.team.workitem.workItemType.task
Note: I am using 6.0.6. And I am using an AJAX request WITHOUT the OSLC version header. Here is my full AJAX request for the work item post:
var simpleWI = new Object();
simpleWI['dc:type'] = new Object();
simpleWI['dc:type'][rdf:resource'] = (Work Item Type URL);
simpleWI['dc:title'] = "Any title you desire";
var str = JSON.stringify(simpleWI);
var URL = RTCURL() + "oslc/contexts/" + ProjectItemId + "/drafts/workitems";
$.ajax({
async:true, xhrFields: {withCredentials: true}, url: URL,
type: 'POST',
data: str,
headers:{
'Content-Type' : 'application/json',
'Accept':'application/json'
},
success: function(response, status, xhr){
let location = xhr.getResponseHeader("location");
let draftId = location.substr(location.indexOf('draftId='));
let url = projectURL + "?" + draftId + "#action=com.ibm.team.workitem.newWorkItem&" + draftId + "&type=" + WITypeId;
window.open(url, "_blank");
},
error: function(error){
alert(error.responseJSON['oslc_cm:message']||error);
}
});
Comments
Donald Nong
Feb 18 '14, 8:54 p.m.Bryan Perino
Feb 18 '14, 9:35 p.m.