Want a nice rest client that just works without too much headache? Try this well rested and ready to go client built on top of apache http client

Check out the Releases page for detailed info about each release.

Examples:

GET Request:

ResponseVO serverResponse = WellRestedRequest.build(url).get();

 

The ResponseVO class contains the status code returned by the server and the server response returned as String.

POST Request:

How to post a json string directly:

ResponseVO serverResponse = WellRestedRequest.build(url).post(jsonString);

 

How to post an object as json:

ResponseVO serverResponse = WellRestedRequest.build(url).post(myObj);

 

How to post an xml string directly:

ResponseVO serverResponse = WellRestedRequest.build(url).post(xmlString, ContentType.APPLICATION_XML);

 

Support for custom date serializers and deserializers and date formats:

Set date format (please note, the date format overrides any set serializers and deserializers):

ResponseVO serverResponse = WellRestedRequest.build(url).setDateFormat("yyyy-MM-dd").post(myObj);

 

Set provided String date serializer with custom format, Long date serializer or your own serializer:

ResponseVO serverResponse = WellRestedRequest.build(url).setDateSerializer(new StringDateSerializer("yyyy/MM/dd")).post(myObj); 
ResponseVO serverResponse = WellRestedRequest.build(url).setDateSerializer(new LongDateSerializer()).post(myObj); 
ResponseVO serverResponse = WellRestedRequest.build(url).setDateSerializer(new MyCustomDateSerializer()).post(myObj); 

 

Set provided date Deserializer with custom formats or your own deserializer:

ResponseVO serverResponse = WellRestedRequest.build(url).setDateDeserializer(new DateDeserializer("yyyy/MM/dd")).post(myObj); 
ResponseVO serverResponse = WellRestedRequest.build(url).setDateDeserializer(new DateDeserializer(Arrays.asList("yyyy/MM/dd", "dd/MM/yyyy"))).post(myObj); 
ResponseVO serverResponse = WellRestedRequest.build(url).setDateDeserializer(new MyCustomDateDeserializer()).post(myObj); 

 

More examples to come…

Usage:

<dependency>
    <groupId>com.lindar</groupId>
    <artifactId>well-rested-client</artifactId>
    <version>1.1.0</version>
</dependency>