OSLC update API and the RRC4.0
We have been trying to update a requirement through the OSLC API ,we were able to properly form the update query and the query is running fine i.e no error response message is coming (status 200 ok) but the issue is when we are looking in RRC UI there is no update reflected.
Can you please let me know where M doing wrong or is there any special header/ httpPut request needs to be fromed or there is extra feature required fro update to be reflected in UI.
Can you please let me know where M doing wrong or is there any special header/ httpPut request needs to be fromed or there is extra feature required fro update to be reflected in UI.
Accepted answer
Hi,
The steps to update an existing artifact in RRC 4.0 are:
1) Get the resource you are trying to update, use following header in the request:
OSLC-Core-Version=2.0
Accept=application/rdf+xml
It should return the rdf+xml content and some headers.
2) Do a Put to the resource using following information returned in step one :
Add headers :
OSLC-Core-Version=2.0
Accept=application/rdf+xml
From the headers returned in step 1, get the value of header "Etag" and add it to a If-Match header, for instance :
If-Match= "_HT1a0eGhEeGWkeyF2C15GA"
Modify the rdf+xml content recieved and add it to the body of the put request, Select the content type as: application/rdf+xml
Refresh ( F5 ) your browser to verify your changes.
The steps to update an existing artifact in RRC 4.0 are:
1) Get the resource you are trying to update, use following header in the request:
OSLC-Core-Version=2.0
Accept=application/rdf+xml
It should return the rdf+xml content and some headers.
2) Do a Put to the resource using following information returned in step one :
Add headers :
OSLC-Core-Version=2.0
Accept=application/rdf+xml
From the headers returned in step 1, get the value of header "Etag" and add it to a If-Match header, for instance :
If-Match= "_HT1a0eGhEeGWkeyF2C15GA"
Modify the rdf+xml content recieved and add it to the body of the put request, Select the content type as: application/rdf+xml
Refresh ( F5 ) your browser to verify your changes.
Comments
2 other answers
I am also seeing the same issue while updating the Requirement using REST API. I get the response code as 200 but update is not being reflected.
Header value content length: 0
- Server: Apache-Coyote/1.1
- OSLC-Core-Version: 2.0
- ETag: "_qXxf8uhKEeGQ1_oJ08nXmQ"
- Content-Type: application/rdf+xml
- Transfer-Encoding: chunked
- Date: Fri, 17 Aug 2012 10:37:58 GMT
eTagValue"_qXxf8uhKEeGQ1_oJ08nXmQ"
>> First PUT URI: https://j<myServer>:9443/rm/resources/_qXvqwehKEeGQ1_oJ08nXmQ
>> Response Code on First PUT: 200
>> Response Headers on First PUT:
- Server: Apache-Coyote/1.1
- OSLC-Core-Version: 2.0
- Content-Type: application/xml
- Transfer-Encoding: chunked
- Date: Fri, 17 Aug 2012 10:37:59 GMT
in Main Method
response code: 200
Response Header:
- Server: Apache-Coyote/1.1
- OSLC-Core-Version: 2.0
- Content-Type: application/xml
- Transfer-Encoding: chunked
- Date: Fri, 17 Aug 2012 10:37:59 GMT
Response Body:
the header i am setting while doing put :
rmPUT.addHeader("Accept", "application/rdf+xml");
rmPUT.addHeader("Content-Type", "application/rdf+xml");
rmPUT.addHeader("OSLC-Core-Version", "2.0");
rmPUT.addHeader("If-Match", rmeTagValue);
Header value content length: 0
- Server: Apache-Coyote/1.1
- OSLC-Core-Version: 2.0
- ETag: "_qXxf8uhKEeGQ1_oJ08nXmQ"
- Content-Type: application/rdf+xml
- Transfer-Encoding: chunked
- Date: Fri, 17 Aug 2012 10:37:58 GMT
eTagValue"_qXxf8uhKEeGQ1_oJ08nXmQ"
>> First PUT URI: https://j<myServer>:9443/rm/resources/_qXvqwehKEeGQ1_oJ08nXmQ
>> Response Code on First PUT: 200
>> Response Headers on First PUT:
- Server: Apache-Coyote/1.1
- OSLC-Core-Version: 2.0
- Content-Type: application/xml
- Transfer-Encoding: chunked
- Date: Fri, 17 Aug 2012 10:37:59 GMT
in Main Method
response code: 200
Response Header:
- Server: Apache-Coyote/1.1
- OSLC-Core-Version: 2.0
- Content-Type: application/xml
- Transfer-Encoding: chunked
- Date: Fri, 17 Aug 2012 10:37:59 GMT
Response Body:
the header i am setting while doing put :
rmPUT.addHeader("Accept", "application/rdf+xml");
rmPUT.addHeader("Content-Type", "application/rdf+xml");
rmPUT.addHeader("OSLC-Core-Version", "2.0");
rmPUT.addHeader("If-Match", rmeTagValue);
The OSLC workshop code have an issue when running against a server 4.0 or above. To fix it you must replace following method in the Example04.java.
protected String findPropertyByTitle(Document doc, String title) throws Exception {
// Vocabulary Support
// based on last Resource shapes changes we need to use dcterms:title to get the property name
String propertyDefinition = "//oslc:Property[dcterms:title=\"" + title +"\"]/oslc:propertyDefinition/@rdf:resource";
XPath xpathNamespace = getXpathNamespace();
Node node = (Node) xpathNamespace.evaluate(propertyDefinition, doc, XPathConstants.NODE);
if(node != null){
return node.getTextContent();
}
return null;
}
With this change code must be able to update the Primary text. PLS let me know if questions
protected String findPropertyByTitle(Document doc, String title) throws Exception {
// Vocabulary Support
// based on last Resource shapes changes we need to use dcterms:title to get the property name
String propertyDefinition = "//oslc:Property[dcterms:title=\"" + title +"\"]/oslc:propertyDefinition/@rdf:resource";
XPath xpathNamespace = getXpathNamespace();
Node node = (Node) xpathNamespace.evaluate(propertyDefinition, doc, XPathConstants.NODE);
if(node != null){
return node.getTextContent();
}
return null;
}
With this change code must be able to update the Primary text. PLS let me know if questions