Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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. 

0 votes

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



I haven't had access to the logs yet. How would I discover what the url is for the types and what name I need to use. Instead of "rtc_cm:type", could it be something different?

I got that URL by following the

Root Doc -> Service Catalog -> Service Provider



7 answers

Permanent link
 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


0 votes

Comments

 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

    
OSLC-Core-Version 2.0
accept application/json
Content-type application/json

and here is the snipet from the log file.


Permanent link
 Hello Brian,
log shows:
  1. org.eclipse.core.runtime.AssertionFailedException: null argument:
  2.         at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:85)
  3.         at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:73)
  4.         at com.ibm.team.workitem.common.internal.workflow.StateGroupRegistry.getStateGroup(StateGroupRegistry.java:
  5. 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"
            }
        ]
    },
		

0 votes

Comments

 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. 

 I actually found the documentation I had been referencing. 



It doesn't state what is needed to create a draft work item.


Permanent link
  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

0 votes


Permanent link
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.

0 votes

Comments
I can create empty drafts with nothing more than a valid dc:type. 

What did you do to get this to fail?


Permanent link
 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

0 votes

Comments

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


Permanent link
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


0 votes

Comments

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

 

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'
'rtc_cm:type':'task'
'rtc_cm:type':{'rdf:resource':'fullURL/task'}
'dc:type':{'rdf:resource':'fullURL/task'}


Any ideas?

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!

 There has been a defect since v3:


I'll try manipulating the URL to specify the type.

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

Permanent link

 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);
    }
});

0 votes

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,943
× 480
× 11
× 6
× 4

Question asked: Feb 18 '14, 5:24 p.m.

Question was seen: 7,876 times

Last updated: Apr 24 '20, 8:02 p.m.

Confirmation Cancel Confirm