Im new for REST and create a client to send data to external hosting. 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 receive request
Representation reply = clientResource.get();
I am using reslet api 2.0.8. This seems like a problem in post org.restlet: posting JSON content against webservice returns HTTP 411 error (length required)
I have the following banks on the way to classes
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.
source share