{8.2.0-new} Request Body

The request body can either be passed in with the client creator method (e.g. {@link oajr.client2.RestClient#post(Object,Object) post(uri,body)}), or can be specified via the following methods:

The request body can be any of the following types:

Examples:

// Create a client with Simple-JSON support. RestClient client = RestClient.create().simpleJson().build(); // Post a JSON-serialized bean. client .post(URI) .body(bean) .complete() .assertStatus().code().is(200); // Post contents from a reader. client .post(URI) .body(new FileReader("/tmp/foo.json")) .complete() .assertStatus().code().is(200); // Post contents from an Apache HttpEntity object. client .post(URI) .body(new StringEntity(jsonString, ContentType.APPLICATION_JSON)) .complete() .assertStatus().code().is(200);