Im new to REST and am developing a client to post data to a external hosted service. Im using org.reslet.resource.ClientResource to create a client
Representation rep = new JsonRepresentation(json);
rep.setMediaType(MediaType.APPLICATION_JSON);
rep.setCharacterSet(CharacterSet.UTF_8);
ClientResource clientResource = getClientResource();
Representation reply = clientResource.post(rep);
return readResponseStream(reply, clientResource);
however I get the following error
Exception in thread "main" Length Required (411) - Length Required
at org.restlet.resource.ClientResource.handle(ClientResource.java:858)
at org.restlet.resource.ClientResource.post(ClientResource.java:1197)
at org.mine.client.impl.RestClient.post(RestClient.java:59)
The same code works for a get request
Representation reply = clientResource.get();
I'm using reslet api 2.0.8. This seems like the problem in post org.restlet: Posting JSON content against webservice returns HTTP error 411 (length required)
I have the following jars in the classpath
org.apache.commons.codec.jar org.apache.commons.logging.jar org.apache.httpclient.jar org.apache.httpcore.jar org.json.jar org.restlet.ext.json.jar org.restlet.jar
Any help would be greatly appreciated.