How to POST form data with Spring RestTemplate?

I want to convert the following (working) curl snippet to a RestTemplate call: curl -i -X POST -d “[email protected]” https://app.example.com/hr/email How do I pass the email parameter correctly? The following code results in a 404 Not Found response: String url = “https://app.example.com/hr/email”; Map<String, String> params = new HashMap<String, String>(); params.put(“email”, “[email protected]”); RestTemplate restTemplate = new … Read more

How to set an “Accept:” header on Spring RestTemplate request?

I want to set the value of the Accept: in a request I am making using Spring’s RestTemplate. Here is my Spring request handling code @RequestMapping( value= “/uom_matrix_save_or_edit”, method = RequestMethod.POST, produces=”application/json” ) public @ResponseBody ModelMap uomMatrixSaveOrEdit( ModelMap model, @RequestParam(“parentId”) String parentId ){ model.addAttribute(“attributeValues”,parentId); return model; } and here is my Java REST client: public … Read more

Spring RestTemplate – how to enable full debugging/logging of requests/responses?

I have been using the Spring RestTemplate for a while and I consistently hit a wall when I’am trying to debug it’s requests and responses. I’m basically looking to see the same things as I see when I use curl with the “verbose” option turned on. For example : curl -v http://twitter.com/statuses/public_timeline.rss Would display both … Read more