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
{
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
Comments
Bryan Perino
commented Feb 20 '14, 1:37 p.m.
Thanks Eric.
I have looked through the documentation and don't see anything glaringly obvious. Here are the headers that I am sending with the request
and here is the snipet from the log file.
|
Hello Brian,
log shows:
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 Perino
commented Feb 25 '14, 11:19 a.m.
What is required to create a draft work item? I keep trying to find the documentation, but I have hard time keeping track of where it is.
Bryan Perino
commented Feb 25 '14, 11:24 a.m.
I actually found the documentation I had been referencing.
It doesn't state what is needed to create a draft work item.
|
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. Comments
I can create empty drafts with nothing more than a valid dc:type.
What did you do to get this to fail? |
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
Comments
Bryan Perino
commented Feb 26 '14, 10:09 a.m.
What would be the best way to open a defect? My company purchased RTC, so should I do it through them?
yes - you may open a formal ticket - aka PMR - https://jazz.net/help/support/
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
Bryan Perino
commented May 28 '14, 2:05 p.m.
Here are the results. I tried it once with dc:type and the other with rtc_cm:type
Neither one seemed to work.
Just to keep the discussion going. I get the same 500 error "null parameter" when I post the below JSON
{ "dcterms:title": "Offer more services related to loans", "rtc_cm:type": { "rdf:type": [ { "rdf:resource": "http://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/Type" } ], "rdf:resource": "https://<server>:<port>/ccm/oslc/types/_YAOpUK2SEeOZZsxCNqN2HA/defect" } }If I post the same content with the same setting to create a WI (not a draft), I get the error "'Save Work Item' failed. Preconditions have not been met: The 'Filed Against' attribute needs to be set (work item <12:44:28>)." as expected.
With out of the box projects, this also works.
{
"dc:type":"defect"
}
joe meagher
commented Dec 13 '17, 8:58 p.m.
Has something changed? It seems the 'type' attribute is ignored in the newer releases (I'm testing on 6.0.4) when creating a draft workitem. I've tried various forms, all are ignored.
'dc:type':'task'
Dave Evans
commented Apr 24 '20, 3:42 p.m.
I'm seeing the same thing. Type seems to be ignored, but the other parts of my JSON are respected. IBM Support told me they don't support OSLC so to come and ask the developers here!
Dave Evans
commented Apr 24 '20, 3:44 p.m.
There has been a defect since v3:
I'll try manipulating the URL to specify the type.
Geoffrey Clemm
commented Apr 24 '20, 8:02 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
If you can provide support with a small program that demonstrates the problem when run against the out-of-the-box Money That Matters project area, they should be willing to reproduce the problem and give you some guidance (or create a defect for the problem). Or in this case, let you know it is a known defect.
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);
}
});
|
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.
Comments
500 internal error can mean anything. You need to check the log file to find out the relevant errors. Also, you did not say what URL you passed the JSON to, and it is difficult for others to imagine what might go wrong.
Sorry about the lack of information. Here is the url that I am sending the request to