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.
- Since:
- 6.1
- Author:
- Arjen Poutsma, Sebastien Deleuze
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.web.client.RestClient.RequestHeadersSpec
RestClient.RequestHeadersSpec.ConvertibleClientHttpResponse, RestClient.RequestHeadersSpec.ExchangeFunction<T extends @Nullable Object>, 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.Set the hint with the given name to the given value forSmartHttpMessageConverters supporting them.Methods inherited from interface org.springframework.web.client.RestClient.RequestHeadersSpec
accept, acceptCharset, apiVersion, 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
-
hint
Set the hint with the given name to the given value forSmartHttpMessageConverters supporting them.- Parameters:
key- the key of the hint to addvalue- the value of the hint to add- Returns:
- this builder
- Since:
- 7.0
-