{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:

- {@link oajr.client2.RestRequest}
  - {@link oajr.client2.RestRequest#body(Object) body(Object)}
  - {@link oajr.client2.RestRequest#body(Object,HttpPartSchema) body(Object,HttpPartSchema)}

The request body can be any of the following types:

- {@link java.lang.Object} - POJO to be converted to text using the {@link oaj.serializer.Serializer} defined on the client or request.
- {@link java.io.Reader} - Raw contents of {@code Reader} will be serialized to remote resource.
- {@link java.io.InputStream} - Raw contents of {@code InputStream} will be serialized to remote resource.
- {@link org.apache.http.HttpEntity} - Bypass Juneau serialization and pass HttpEntity directly to HttpClient.
- {@link oaj.http.NameValuePairSupplier} - Converted to a URL-encoded FORM post.
- {@link java.util.function.Supplier} - A supplier of anything on this list.

##### 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);

- If the serializer on the client or request is explicitly set to null, POJOs will be converted to strings using the registered part serializer as content type "text/plain. If the part serializer is also null, POJOs will be converted to strings using {@link oaj.ClassMeta#toString(Object)} which typically just calls {@link java.lang.Object#toString()}.