Is there a way to add or modify a timesheet entry to an RTC workitem via REST API?
I've been looking through the RTC REST API, but couldn't find a way to programmatically create a timesheet entry via REST. Can this be done at all? If so, how can I do it?
I tried to use the GET/PUT mechanism to modify an already existing collection of TimeSheetEntry, but I keep getting a 405 error no matter what I do.
<?xml version="1.0" encoding="UTF-8"?><oslc_cm:error xmlns:oslc_cm="http://open-services.net/xmlns/cm/1.0/"> <oslc_cm:status>405</oslc_cm:status> <oslc_cm:message/> </oslc_cm:error> This what I've done so far: 1. GET https://***:9443/ccm/oslc/workitems/156/rtc_cm:timeSheet response: <?xml version="1.0" encoding="UTF-8"?><rtc_cm:TimeSheet xmlns:rtc_cm="http://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/" rdf:about="https://stend-402.aplana.com:9443/ccm/oslc/workitems/156/rtc_cm:timeSheet" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:oslc_cm="http://open-services.net/xmlns/cm/1.0/"> 2. GET https://***:9443/ccm/oslc/workitems/156/rtc_cm:timeSheet/rtc_cm:entry response: <?xml version="1.0" encoding="UTF-8"?><oslc_cm:Collection xmlns:oslc_cm="http://open-services.net/xmlns/cm/1.0/" oslc_cm:totalCount="2" xmlns:dc="http://purl.org/dc/terms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rtc_cm="http://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/">3. PUT/POST https://***:9443/ccm/resource/itemOid/com.ibm.team.workitem.TimeSheetEntry/_86jcF652EeKBe6dbNNyQ5w <rtc_cm:TimeSheetEntry xmlns:oslc_cm="http://open-services.net/xmlns/cm/1.0/" oslc_cm:totalCount="2" xmlns:dc="http://purl.org/dc/terms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rtc_cm="http://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/"> and here I get the 405 error. I also tried to POST and PUT a new collecton of timesheet entries like this: POST/PUT https://***:9443/ccm/oslc/workitems/156/rtc_cm:timeSheet/rtc_cm:entry <?xml version="1.0" encoding="UTF-8"?><oslc_cm:Collection xmlns:oslc_cm="http://open-services.net/xmlns/cm/1.0/" oslc_cm:totalCount="0"/> I expected this to replace the existing TimeSheetEntry collection with an empty one but I still get 405.
|
Accepted answer
timeSheet and timeSheetEntry creation (POST) and update (PUT) are not available via the REST API. Those resources are only available via GET. So, the 405 (method not allowed) is a correct response from the server.
You can use the Java API to create and update time sheets. See https://jazz.net/wiki/bin/view/Main/OSLCAccessForTimesheetEntry for details on what the REST API supports today and a snippet of code on how to use the Java API
Serghei Zagorinyak selected this answer as the correct answer
Comments
Serghei Zagorinyak
commented May 07 '13, 8:36 a.m.
1. I used the code from this link: https://jazz.net/wiki/bin/view/Main/OSLCAccessForTimesheetEntry and was able to create a timesheet for a workitem, however, the code throws an exception on workingCopyManager.dispose(); line. It says: org.eclipse.core.runtime.AssertionFailedException: assertion failed: at org.eclipse.core.runtime.Assert.isTrue(Assert.java:110) at org.eclipse.core.runtime.Assert.isTrue(Assert.java:96) at com.ibm.team.workitem.client.internal.WorkItemWorkingCopyManager.dispose(WorkItemWorkingCopyManager.java:178) at com.***.timesheet.TimesheetService.addTimeSheetEntry(TimesheetService.java:54) ... All I did was getting a workitem and passing it into the addTimeSheetEntry method. This doesn't seem to affect timesheet creation but clutters logfiles. Can this be fixed?
2. One more thing is that when a timesheet entry is added with the same starting time, same timecode and same owner more than once, then only the last timesheet info is displayed in the CCM WebUI. The last value is also used for calculation of week total field, while the sum of all timesheets is used for the task total field. I.e. if we add timesheets with duration of 2, 4 and 8 hours, week total will be 8 and task total will be 14 hours, while only 8 hrs record is displayed in Web UI.
Thank you for your replies! I'm getting a number of errors logged on workitem creation. The call IWorkItemType workItemType = workItemClient.findWorkItemType(projectAreaHandle, "task", null);causes these erros to show up: 13.05.2013 12:22:11 com.ibm.team.foundation.common.util.FoundationLog unexpectedError SEVERE: URL not found: processattachment:/workitemtype/Issue_bitmap.bmp 13.05.2013 12:22:11 com.ibm.team.foundation.common.util.FoundationLog unexpectedError SEVERE: URL not found: processattachment:/workitemtype/enhancement.gif 13.05.2013 12:22:11 com.ibm.team.foundation.common.util.FoundationLog unexpectedError SEVERE: URL not found: processattachment:/workitemtype/general.gif 13.05.2013 12:22:11 com.ibm.team.foundation.common.util.FoundationLog unexpectedError SEVERE: URL not found: processattachment:/workitemtype/gear.png 13.05.2013 12:22:11 com.ibm.team.foundation.common.util.FoundationLog unexpectedError SEVERE: URL not found: processattachment:/workitemtype/unknown.gifLooks like this is an issue of RTC configuration. How can this be solved? |
One other answer
Thank you for the replies!
I'm also getting errors from IWorkItemHandle handle = workItemClient.getWorkItemWorkingCopyManager().connectNew(workItemType, null);: 13.05.2013 12:25:31 com.ibm.team.foundation.common.util.FoundationLog unexpectedError SEVERE: Default value provider not found: com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider 13.05.2013 12:25:33 com.ibm.team.foundation.common.util.FoundationLog unexpectedError SEVERE: Value provider not found: com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProviderI tried to add the following jars: com.ibm.team.rtc.common.scriptengine_3.1.200.v20120924_1445.jar com.ibm.team.workitem.api.common_3.1.200.v20121022_1010.jar com.ibm.team.workitem.shared.common_3.1.200.v20121022_1010.jar org.mozilla.javascript_1.7.2.v201005080400.jarto the build path, as they contain the ScriptAttributeValueProvider definition and referenced classes, but in this case I'm getting an Exception: Exception in thread "main" java.lang.ExceptionInInitializerError at org.eclipse.core.runtime.FileLocator.find(FileLocator.java:84) at com.ibm.team.rtc.common.scriptengine.environment.FileScriptFeature.findFile(FileScriptFeature.java:107) at com.ibm.team.rtc.common.scriptengine.environment.FileScriptFeature.create(FileScriptFeature.java:50) at com.ibm.team.rtc.common.scriptengine.environment.FileScriptFeature.create(FileScriptFeature.java:46) at com.ibm.team.rtc.common.scriptengine.environment.dojo.DojoFeature.This also loks like a misconfigured RTC to me. How can I fix this? |
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.