Package org.springframework.web.client

# Class UnknownContentTypeException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.springframework.core.NestedRuntimeException
org.springframework.web.client.RestClientException
org.springframework.web.client.UnknownContentTypeException

All Implemented Interfaces:
  `Serializable`

public class UnknownContentTypeException extends RestClientException
Raised when no suitable `HttpMessageConverter` could be found to extract the response.

Since:
  5.2.7
Author:
  Rossen Stoyanchev
See Also:
  - Serialized Form

## Constructor Summary

Constructors
Constructor
Description
`UnknownContentTypeException(Type targetType, MediaType contentType, int statusCode, String statusText, HttpHeaders responseHeaders, byte[] responseBody)`
Construct a new instance of with the given response data.
`UnknownContentTypeException(Type targetType, MediaType contentType, HttpStatusCode statusCode, String statusText, HttpHeaders responseHeaders, byte[] responseBody)`
Construct a new instance of with the given response data.

## Method Summary

Modifier and Type
Method
Description
`MediaType`
`getContentType()`
Return the content type of the response, or "application/octet-stream".
`int`
`getRawStatusCode()`
Deprecated.
in favor of `getStatusCode()`, for removal in 7.0
`byte[]`
`getResponseBody()`
Return the response body as a byte array.
`String`
`getResponseBodyAsString()`
Return the response body converted to String using the charset from the response "Content-Type" or `"UTF-8"` otherwise.
`HttpHeaders`
`getResponseHeaders()`
Return the HTTP response headers.
`HttpStatusCode`
`getStatusCode()`
Return the HTTP status code value.
`String`
`getStatusText()`
Return the HTTP status text.
`Type`
`getTargetType()`
Return the target type expected for the response.

### Methods inherited from class org.springframework.core.NestedRuntimeException

`contains, getMostSpecificCause, getRootCause`

### Methods inherited from class java.lang.Throwable

`addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### UnknownContentTypeException

public UnknownContentTypeException(Type targetType, MediaType contentType, int statusCode, String statusText, HttpHeaders responseHeaders, byte[] responseBody)
Construct a new instance of with the given response data.

Parameters:
  `targetType` - the expected target type
  `contentType` - the content type of the response
  `statusCode` - the raw status code value
  `statusText` - the status text
  `responseHeaders` - the response headers (may be `null`)
  `responseBody` - the response body content (may be `null`)

### UnknownContentTypeException

public UnknownContentTypeException(Type targetType, MediaType contentType, HttpStatusCode statusCode, String statusText, HttpHeaders responseHeaders, byte[] responseBody)
Construct a new instance of with the given response data.

Parameters:
  `targetType` - the expected target type
  `contentType` - the content type of the response
  `statusCode` - the raw status code value
  `statusText` - the status text
  `responseHeaders` - the response headers (may be `null`)
  `responseBody` - the response body content (may be `null`)
Since:
  6.0

## Method Details

### getTargetType

public Type getTargetType()
Return the target type expected for the response.

### getContentType

public MediaType getContentType()
Return the content type of the response, or "application/octet-stream".

### getStatusCode

public HttpStatusCode getStatusCode()
Return the HTTP status code value.

### getRawStatusCode

@Deprecated(since="6.0") public int getRawStatusCode()
Deprecated.
in favor of `getStatusCode()`, for removal in 7.0
Return the raw HTTP status code value.

### getStatusText

public String getStatusText()
Return the HTTP status text.

### getResponseHeaders

@Nullable public HttpHeaders getResponseHeaders()
Return the HTTP response headers.

### getResponseBody

public byte[] getResponseBody()
Return the response body as a byte array.

### getResponseBodyAsString

public String getResponseBodyAsString()
Return the response body converted to String using the charset from the response "Content-Type" or `"UTF-8"` otherwise.