It's all about the answers!

Ask a question

Update artifacts in RRC using OSLC


Samanwita Majumdar (5033740) | asked Sep 18 '12, 3:44 a.m.
I am trying to update the plain text of an artifact using OSLC. I used OSLC to create the same artifact and that worked fine. While trying to update it throws a forbidden exception (Using same credentials as create). Also I am working on CLM 4.0. Here is the code snippet that I am using to PUT the artifact:

HttpPut put = new HttpPut(requirementURL);
        put.addHeader("Accept", "application/rdf+xml");
        put.addHeader("Content-Type", "application/rdf+xml");
        put.addHeader("OSLC-Core-Version", "2.0");
        put.addHeader("If-Match", requirementURL);
        //put.setEntity(new StringEntity(updatedContent, HTTP.UTF_8));
        //put.setEntity(new StringEntity(newContent, HTTP.UTF_8));
        put.setEntity(new StringEntity("test", HTTP.UTF_8));
        reqResponse = HttpUtils.sendPutForSecureDocument(server, put, login, password, httpclient, JTS_Server);
        reqResponse.getEntity().consumeContent();
        if (reqResponse.getStatusLine().getStatusCode() != 200) {
            throw new HttpResponseException(reqResponse.getStatusLine()
                    .getStatusCode(), reqResponse.getStatusLine()
                    .getReasonPhrase());
        }
        //If we get here then our PUT succeeded and the requirement should have our link now
       

The control goes to the throws block as the status code is 403 and not 200.
Is there anything specific that I need to do for this?

3 answers



permanent link
Gabriel Ruelas (1.1k13) | answered Sep 19 '12, 9:39 a.m.
Etag is a header returned as a response to the artifact POST creation or when doing an artifact OSLC GET.

For instance, do a GET to https://ch5dlfi077.in.ibm.com:9445/rm/resources/_NUfpYQHlEeKKAukOYXiD1A and the returned information will include the Etag header.

permanent link
Samanwita Majumdar (5033740) | answered Sep 19 '12, 2:06 a.m.
Hi Gabriel,

I tried the option that you suggested. What do you mean when you say Etag is it the resource id or the artifact's internal id ? I tried putting the artifact id from this URL

reqURL ... https://ch5dlfi077.in.ibm.com:9445/rm/resources/_NUfpYQHlEeKKAukOYXiD1A

and my If-Match = "_NUfpYQHlEeKKAukOYXiD1A"

Still I get the same Forbidden error.

Is there anything specific way to get the eTag attribute?

Thanks,
Samanwita

permanent link
Gabriel Ruelas (1.1k13) | answered Sep 18 '12, 10:13 a.m.
The value for the If-Match header should be the value returned in the Etag field of the artifact creation or in an OSLC GET of the artifact.
An example of a returned etag header is :
etag= "_4hAL8QGaEeKhxJRuLyAnpg"

and should be used in the OSLC PUT as :
If-Match= "_4hAL8QGaEeKhxJRuLyAnpg"


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.