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
  • Method Details

    • contentLength

      RestClient.RequestBodyspec&nbsp;contentLength(long&nbsp;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:
    • contentType

      RestClient.RequestBodyspec&nbsp;contentType(MediaType&nbsp;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:
    • body

      RestClient.RequestBodyspec&nbsp;body(Object&nbsp;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>&nbsp;RestClient.RequestBodyspec&nbsp;body(T&nbsp;body, ParameterizedTypeReference<T>&nbsp;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

      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
    • hint

      RestClient.RequestBodyspec&nbsp;hint(string&nbsp;key, Object&nbsp;value)
      set the hint with the given name to the given value for smartHttpMessageConverters supporting them.
      Parameters:
      key - the key of the hint to add
      value - the value of the hint to add
      Returns:
      this builder
      since:
      7.0