{title:'@Content', updated:'8.2.0', updated:'9.0.0'}

The {@link oaj.http.annotation.Content @Content} annotation can be applied to arguments of @RemoteOp-annotated methods to denote that they are the HTTP body of the request.

- {@link oaj.http.annotation.Content}
  - {@link oaj.http.annotation.Content#schema() schema}

##### Examples:

| // Used on parameter | @Remote(path="/petstore") | public interface PetStore { | | @RemotePost("/pets") | String addPet(@Content Pet pet); | }

| // Used on class | @Remote(path="/petstore") | public interface PetStore { | | @RemotePost("/pets") | String addPet(Pet pet); | } | | @Content | public class Pet {...}

The argument can be any of the following types:

- Any serializable POJO - Converted to output using the {@link oaj.serializer.Serializer} registered with the RestClient.
  Content-Type is set to that of the Serializer.
- {@link java.io.Reader} - Raw contents of {@code Reader} will be serialized to remote resource.
  Content-Type is set to "text/plain".
- {@link java.io.InputStream} - Raw contents of {@code InputStream} will be serialized to remote resource.
  Content-Type is set to "application/octet-stream".
- {@link oaj.http.part.PartList} - Converted to a URL-encoded FORM post.
  Content-Type is set to "aplication/x-www-form-urlencoded".
- HttpEntity - Bypass Juneau serialization and pass HttpEntity directly to HttpClient.

OpenAPI schema based serialization can be used by using the {@link oaj.oapi.OpenApiSerializer} class.

| @RemotePost("/comma-delimited-pipe-delimited-ints") | String addCommaDelimitedPipeDelimitedInts( | @Content( | serializer=OpenApiSerializer. class, | schema=@Schema( | type="array", | collectionFormat="pipes", | items=@Items( | type="array" | items=@SubItems( | type="int32", | // Auto-validates on client side! | minimum="0", | maximum="64" | ) | ) | ) | ) | int[][] input | );

| // Same as above but using free-form schema. | // Format is simplified-JSON (outer {} brackets are optional). | @RemotePost("/comma-delimited-pipe-delimited-ints") | String addCommaDelimitedPipeDelimitedInts( | @Content( | serializer=OpenApiSerializer. class, | schema=@Schema( | "type:'array',collectionFormat:'pipes',items:[type:'array',items:[type:'int32',minimum:0,maximum:64]]" | ) | ) | int[][] input | );

See OpenAPI Serializers for information about supported data types in OpenAPI serialization.

If your RestClient class does not have a serializer associated with it, the body will automatically be serialized to a string using the rules defined in POJO Categories.