Post problems when using Restlet Javascript Edition...
2012-02-09 19:32:49 GMT
Working on a small project to learn REST/Restlet and ran into a problem where I can successfully post from a Java client to my server or from an HTML form to my server, but when I try to post from Javascript it fails. I am following the sample code that is now on github (https://github.com/restlet/restlet-framework-js/tree/master/tests/org.restlet.js.tests/src/browser/static/html). On the client side... For Java (working), I have: System.out.println("Adding a commitment"); ClientResource client3 = new ClientResource("http://localhost:8888/commitments/"); client3.setRequestEntityBuffering(true); // Per http://stackoverflow.com/questions/6462142/length-required-411-length-required-in-a-restlet-client Commitment commitment3 = new Commitment(); commitment3.setTitle("Added through post - Java client"); commitment3.setDescription("This is a description of post Java client"); Representation representation3 = client3.post(commitment3); For Javascript (not working), I have: asyncTest("Post with resource Commitment (json)", function() { var clientResource = new ClientResource("/commitments/"); var commitment = { title: "From automated test", description: "This is from our automated test" } var jsonRepresentation = new JsonRepresentation(commitment); alert(jsonRepresentation.getText()); // Result is: {"title":"From automated test","description":"This is from our automated test"}(Continue reading)
RSS Feed