Home

RequestBody

RequestBody is a term used in HTTP client libraries to describe the data carried in the body of an HTTP request. It represents the payload that a client sends to a server, as opposed to data sent in the URL query string or in headers. A RequestBody typically includes both the content itself and metadata such as the media type (also called Content-Type) and, sometimes, the content length.

In practice, a RequestBody can carry various kinds of data, including plain text, JSON, binary data, form-encoded

In widely used ecosystems such as OkHttp and Retrofit, RequestBody is used to supply the payload to

Key considerations when using RequestBody include memory usage and performance (buffered versus streaming bodies), the ability

data,
or
multipart
form
data
used
for
file
uploads.
Implementations
provide
ways
to
create
a
body
from
strings,
byte
arrays,
files,
or
input
streams,
and
to
specify
the
appropriate
content
type.
Some
libraries
offer
specialized
subclasses
or
builders
for
common
formats,
such
as
simple
text
bodies,
form
bodies,
or
multipart
bodies
that
combine
several
parts.
requests.
It
may
be
created
directly
for
raw
payloads
or
produced
by
higher-level
converters
that
serialize
objects
to
a
desired
format
(for
example,
JSON).
For
multipart
requests,
separate
structures
often
model
the
individual
parts,
while
a
RequestBody
represents
the
overall
payload.
to
stream
large
data,
and
the
correct
specification
of
the
content
length
or
transfer
encoding.
Understanding
the
content
type
and
encoding
is
essential
for
interoperability
with
servers.