How do you update workitems using Perl LWP UserAgent?
I've been trying to post a new workitem to my RTC server then try to use a PUT to update the state of the workitem. So far, I only get a 406 not acceptable error. Here's a section of the code I'm running:
my $url = 'https://serveraddress:9443/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/' . $workItemID;
my @hdrs = (
'Accept' => 'application/xml',
'OSLC-Core-Version' => '2.0',
'Content_Type' => 'application/xml');
my $response = $userAgent->get($url, @hdrs);
my $str = $response->as_string;
my $find = "request.workflow.state.oldState";
my $replace = "request.workflow.state.newState";
$find = quotemeta $find;
$str =~ s/$find/$replace/g;
my @etag = split("ETag:", $str);
@etag = split("\"", $etag[1]);
my $etag_value = $etag[1];
my @strArray = split("encoding=", $str);
$str = "<?xml version=\"1.0\" encoding=" . $strArray[1];
@hdrs = (
'Accept' => '/',
'Content_Type' => 'application/rdf+xml',
'if-match' => $etag_value,
'Content' => $str);
my $url = new URI::URL('https://serveraddress:9443/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/' . $workItemID);
my $request = HTTP::Request->new("PUT", $url);
my $response = $userAgent->request($request, @hdrs);
One answer
You cannot modify the state of work item directly using OSLC (via PUT). You have to invoke an "action" to change the state, just like you do on the Web UI. Some discussions in the past may help you a bit.
https://jazz.net/forum/questions/32674/change-workitem-state-via-rest
https://jazz.net/forum/questions/152920/how-find-available-actions-to-change-states-in-rtc-with-oslc