Attached is a sample Java client that does various REST operations using local files. This client basically reproduces some of the functionality that the curl application has ( http://curl.haxx.se/ ).
Attached is a sample Java client that does various REST operations using local files. This client basically reproduces some of the functionality that the curl application has ( http://curl.haxx.se/ ).
You can make things as complicated or as simple as you like, but it boils down to needing to be able to issue various HTTP requests, and being able to interpret XML that comes back.
The basics to think about with REST are that HTTP methods translate to different operations, so:
HTTP PUT == create new object
HTTP GET == read object
HTTP POST == update object
HTTP DELETE == delete object
All objects in REST have a URI. So, every defect in the system has a unique URI. Queries have unique URIs, etc.. If I want to update some defect, I POST an XML document to that defect's URI. If I want to delete a particular defect, I issue an HTTP DELETE request to that URI, etc.
Our web services docs ( https://rally1.rallydev.com/slm/doc/webservice ) explains most of this in pretty good detail (click on the "REST" link on the left).
Comments
On updates I was getting the following error using this RESTClient code for a POST (update)
<?xml version="1.0" encoding="UTF-8"?>
<OperationResult rallyAPIMajor="1" rallyAPIMinor="9">
<Errors>
<OperationResultError>Cannot parse input stream as XML document: Error on line -1: Premature end of file.</OperationResultError>
</Errors>
<Warnings />
</OperationResult>
To fix this problem I set the content type to "text/xml" with the following line just after the "Authorization" property is set:
connection.setRequestProperty("Content-Type","text/xml");