{8.2.0-new} Request Form Data

Per-client or per-request form-data parameters can be specified using the following methods:

- {@link oajr.client2.RestClientBuilder}
  - {@link oajr.client2.RestClientBuilder#formData(String,Object) formData(String,Object)}
  - {@link oajr.client2.RestClientBuilder#formData(String,Object,HttpPartSchema) formData(String,Object,HttpPartSchema)}
  - {@link oajr.client2.RestClientBuilder#formData(String,Supplier) formData(String,Supplier<?>)}
  - {@link oajr.client2.RestClientBuilder#formData(String,Supplier,HttpPartSchema) formData(String,Supplier<?>,HttpPartSchema)}
  - {@link oajr.client2.RestClientBuilder#formDatas(Object...) formDatas(Object...)}
  - {@link oajr.client2.RestClientBuilder#formDataPairs(Object...) formDataPairs(Object...)}
- {@link oajr.client2.RestRequest}
  - {@link oajr.client2.RestRequest#formData(String,Object) formData(String,Object)}
  - {@link oajr.client2.RestRequest#formData(AddFlag,String,Object) formData(AddFlag,String,Object)}
  - {@link oajr.client2.RestRequest#formDatas(Object...) formDatas(Object...)}
  - {@link oajr.client2.RestRequest#formDatas(AddFlag,Object...) formDatas(AddFlag,Object...)}
  - {@link oajr.client2.RestRequest#formDataPairs(Object...) formDataPairs(Object...)}
  - {@link oajr.client2.RestRequest#formDataCustom(Object) formDataCustom(Object)}

##### Example:

// Create a client that adds a foo=bar form-data parameter to every request. RestClient client = RestClient.create().formData("foo","bar").build(); // Or do it on every request. String response = client.formPost(URI).formData("foo","bar").run().getBody().asString();

{@link oajr.client2.RestClientBuilder#formDatas(Object...) formDatas(Object...)} allows you to pass in a variety of form-data parameter objects, and {@link oajr.client2.RestClientBuilder#formDataPairs(Object...) formDataPairs(Object...)} allows you to specify several form-data parameters in a compact fashion.

##### Example:

// Create a client that adds a bunch of form-data parameters to every request. RestClient client = RestClient .create() .formDatas( AMap.of("foo","bar","baz","qux") // Arbitrary key/value pairs. BasicNameValuePair.of("foo","bar") // A NameValuePair object. BasicNameValuePair.of("foo",()->getBar()) // A dynamic NameValuePair object. NameValuePairSupplier.ofPairs("foo","bar") // A dynamically changing list of NameValuePair objects. AList.of(BasicNameValuePair.of("foo","bar")) // A list of anything else on this list. ) .formDataPairs("foo","bar","baz","qux") .build();

The {@link oaj.httppart.HttpPartSchema} API allows you to define OpenAPI schemas to POJO data structures on form-data parameters.

##### Example:

// Create a client that adds a form-data parameter "foo=bar|baz" to every request. RestClient client = RestClient .create() .formData("foo", AList.of("bar","baz"), T_ARRAY_PIPES) .build();

The methods with {@link oaj.AddFlag} parameters allow you to control whether new form-data parameters get appended, prepended, or replace existing form-data parameters with the same name.

- Like header values, dynamic values and OpenAPI schemas are supported.
- Methods that pass in POJOs convert values to strings using the part serializers. Methods that pass in NameValuePair objects use the values returned by that bean directly.