Other Useful Methods

The {@link oajrc.RestClientBuilder#rootUrl(Object)} method can be used to specify a root URL on all requests so that you don't have to use absolute paths on individual calls.

// Create a rest client with a root URL RestClient rc = RestClient. create().rootUrl("http://localhost:9080/foobar").build(); String r = rc.doGet("/baz").getResponseAsString(); // Gets "http://localhost:9080/foobar/baz"

The {@link oajrc.RestClientBuilder#set(String,Object)} method can be used to set serializer and parser properties.
For example, if you're parsing a response into POJOs and you want to ignore fields that aren't on the POJOs, you can use the {@link oaj.BeanContext#BEAN_ignoreUnknownBeanProperties} property.

// Create a rest client that ignores unknown fields in the response RestClient rc = RestClient. create() .set(BEAN_ignoreUnknownBeanProperties, true) // or .ignoreUnknownBeanProperties(true) .build(); MyPojo myPojo = rc.doGet(URL).getResponse(MyPojo. class);

The {@link oajrc.RestCall#retryable(int,long,RetryOn)} method can be used to automatically retry requests on failures.
This can be particularly useful if you're attempting to connect to a REST resource that may be in the process of still initializing.

// Create a rest call that retries every 10 seconds for up to 30 minutes as long as a connection fails // or a 400+ is received. restClient.doGet(URL) .retryable(180, 10000, RetryOn. DEFAULT) .run();