It's all about the answers!

Ask a question

How to update testcase using OSLC api


Chaitali Kulkarni (1525) | asked Jan 10 '18, 3:21 a.m.

 Hi ,

I am trying to update testcase using apache http client and oslc .
Put request is as follows:

String testcaseUpdateURL : https://<server>:<port>/qm/oslc_qm/context/<context_id>/resources/com.ibm.rqm.planning.VersionedTestCase?oslc.where=oslc:shortId=%22<testcase_id>%22.

HttpPut updateTC = new HttpPut(testcaseUpdateURL );
updateTC.addHeader("Accept", "application/xml");
updateTC.addHeader("Content-type", "application/rdf+xml");
updateTC.addHeader("OSLC-Core-Version","2.0");
                        updateTC.setEntity(entity); // entity is xml data encoded in UTF_8 format

HttpResponse updateTcResponse =  HttpUtils.sendPutForSecureDocument(
server, updateTC , login, password, httpclient);
System.out.println(updateTcResponse.getStatusLine().getStatusCode());

I got output as 302

Accepted answer


permanent link
Jim Amsden (29347) | answered Jan 10 '18, 8:06 a.m.

 The URL you are using is an OSLC query, not the URL of a resource. PUT would not be possible on a query URL.

Chaitali Kulkarni selected this answer as the correct answer

Comments
Chaitali Kulkarni commented Jan 10 '18, 10:55 p.m.

Yeah, I was hitting invalid url. I can now able to update testcase.

One other answer



permanent link
Donald Nong (14.5k614) | answered Jan 10 '18, 11:01 p.m.

I suspect that you were being redirected to the login page because you did not authenticate to the server properly. It appears that you tried to do Basic Authentication during the PUT, which is not possible when most servers are using Form Based Authentication (by default).

To authenticate, you need to POST to /qm/authenticated/j_security_check. See the comment section in the OSLC Workshop and another article for sample codes.
https://jazz.net/library/article/635
https://jazz.net/library/article/633

As Jim mentioned, you have to PUT to a resource URI, not a query URL, for the update. For more details, see the document.
https://jazz.net/wiki/bin/view/Main/RqmOslcQmV2Api#HTTP_PUT_POST_Requests

Note that the URL for partial update looks a bit like a query URL, but it is not, as the first part of it is still a proper resource URI. For example:
https://clm.jkebanking.net:9443/qm/oslc_qm/contexts/_8aqdofQkEeex1tX1crJPcQ/resources/com.ibm.rqm.planning.VersionedTestCase/_pfYp8fQlEeex1tX1crJPcQ?oslc.properties=dcterms:title

Your answer


Register or 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.