lundi 13 avril 2015

Spring 4.1.0 RestTemplate POST call

I am trying to make a rest call using spring 4.1.0 RestTemplate but i dont see HttpEntity class.



HttpHeaders requestHeaders=new HttpHeaders();
requestHeaders.set("Content-Type", "application/json");
String str = new String();
HttpEntity<String> requestEntity=new HttpEntity<String>(str,requestHeaders);
RestTemplate restTemplate=new RestTemplate();
URI location = restTemplate.postForLocation("http://example.com", entity);


So there are 2 questions:




  1. How can i get access to HttpEntity class as its not found?

  2. how can i get the body or the response from URI?



Kindly suggest


Aucun commentaire:

Enregistrer un commentaire