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

How to update testcase using OSLC api

 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

0 votes


Accepted answer

Permanent link

 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

0 votes

Comments

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


One other answer

Permanent link

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

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,938
× 30

Question asked: Jan 10 '18, 3:21 a.m.

Question was seen: 2,865 times

Last updated: Jan 10 '18, 11:01 p.m.

Confirmation Cancel Confirm