Package org.springframework.web.client

# Interface RestClient.RequestBodySpec

All Superinterfaces:
  `RestClient.RequestHeadersSpec<RestClient.RequestBodySpec>`

All Known Subinterfaces:
  `RestClient.RequestBodyUriSpec`

Enclosing interface:
  RestClient

public static interface RestClient.RequestBodySpec extends RestClient.RequestHeadersSpec<RestClient.RequestBodySpec>
Contract for specifying request headers and body leading up to the exchange.

## Nested Class Summary

## Nested classes/interfaces inherited from interface org.springframework.web.client.RestClient.RequestHeadersSpec

`RestClient.RequestHeadersSpec.ConvertibleClientHttpResponse, RestClient.RequestHeadersSpec.ExchangeFunction<T>, RestClient.RequestHeadersSpec.RequiredValueExchangeFunction<T>`

## Method Summary

Modifier and Type
Method
Description
`RestClient.RequestBodySpec`
`body(Object body)`
Set the body of the request to the given `Object`.
`RestClient.RequestBodySpec`
`body(StreamingHttpOutputMessage.Body body)`
Set the body of the request to the given function that writes to an `OutputStream`.
`<T> RestClient.RequestBodySpec`
`body(T body, org.springframework.core.ParameterizedTypeReference<T> bodyType)`
Set the body of the request to the given `Object`.
`RestClient.RequestBodySpec`
`contentLength(long contentLength)`
Set the length of the body in bytes, as specified by the `Content-Length` header.
`RestClient.RequestBodySpec`
`contentType(MediaType contentType)`
Set the media type of the body, as specified by the `Content-Type` header.

### Methods inherited from interface org.springframework.web.client.RestClient.RequestHeadersSpec

`accept, acceptCharset, attribute, attributes, cookie, cookies, exchange, exchange, exchangeForRequiredValue, exchangeForRequiredValue, header, headers, httpRequest, ifModifiedSince, ifNoneMatch, retrieve`

## Method Details

### contentLength

RestClient.RequestBodySpec contentLength(long contentLength)
Set the length of the body in bytes, as specified by the `Content-Length` header.

Parameters:
  `contentLength` - the content length
Returns:
  this builder
See Also:
  - `HttpHeaders.setContentLength(long)`

### contentType

RestClient.RequestBodySpec contentType(MediaType contentType)
Set the media type of the body, as specified by the `Content-Type` header.

Parameters:
  `contentType` - the content type
Returns:
  this builder
See Also:
  - `HttpHeaders.setContentType(MediaType)`

### body

RestClient.RequestBodySpec body(Object body)
Set the body of the request to the given `Object`. For example:

     Person person = ... ;
     ResponseEntity<Void> response = client.post()
         .uri("/persons/{id}", id)
         .contentType(MediaType.APPLICATION_JSON)
         .body(person)
         .retrieve()
         .toBodilessEntity();

Parameters:
  `body` - the body of the request
Returns:
  this builder

### body

<T> RestClient.RequestBodySpec body(T body, org.springframework.core.ParameterizedTypeReference<T> bodyType)
Set the body of the request to the given `Object`. The parameter `bodyType` is used to capture the generic type.

Parameters:
  `body` - the body of the request
  `bodyType` - the type of the body, used to capture the generic type
Returns:
  this builder

### body

RestClient.RequestBodySpec body(StreamingHttpOutputMessage.Body body)
Set the body of the request to the given function that writes to an `OutputStream`.

Parameters:
  `body` - a function that takes an `OutputStream` and can throw an `IOException`
Returns:
  this builder