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 TypeMethodDescriptionSet the body of the request to the givenObject.Set the body of the request to the given function that writes to anOutputStream.body(T body, ParameterizedTypeReference<T> bodyType) Set the body of the request to the givenObject.contentLength(long contentLength) Set the length of the body in bytes, as specified by theContent-Lengthheader.contentType(MediaType contentType) Set the media type of the body, as specified by theContent-Typeheader.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
Set the length of the body in bytes, as specified by theContent-Lengthheader.- Parameters:
contentLength- the content length- Returns:
- this builder
- See Also:
-
contentType
Set the media type of the body, as specified by theContent-Typeheader.- Parameters:
contentType- the content type- Returns:
- this builder
- See Also:
-
body
Set the body of the request to the givenObject. 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
Set the body of the request to the givenObject. The parameterbodyTypeis used to capture the generic type.- Parameters:
body- the body of the requestbodyType- the type of the body, used to capture the generic type- Returns:
- this builder
-
body
Set the body of the request to the given function that writes to anOutputStream.- Parameters:
body- a function that takes anOutputStreamand can throw anIOException- Returns:
- this builder
-