Interface specifying a basic set of RESTful operations.
Implemented by
RestTemplate
. Not often used directly, but a useful
option to enhance testability, as it can easily be mocked or stubbed.
Since:
Author:
Arjen Poutsma, Juergen Hoeller
See Also:
RestTemplate
Object
... uriVariables)
Execute the HTTP method to the given URI template, writing the given request entity to the request, and
returns the response as
ResponseEntity
.
Execute the HTTP method to the given URI template, writing the given request entity to the request, and
returns the response as
ResponseEntity
.
Execute the HTTP method to the given URI template, writing the given
request entity to the request, and returns the response as
ResponseEntity
.
Execute the HTTP method to the given URI template, writing the given
request entity to the request, and returns the response as
ResponseEntity
.
Execute the HTTP method to the given URI template, writing the given request entity to the request, and
returns the response as
ResponseEntity
.
Execute the HTTP method to the given URI template, writing the given
request entity to the request, and returns the response as
ResponseEntity
.
Retrieve an entity by doing a GET on the specified URL.
Retrieve a representation by doing a GET on the URI template.
Retrieve a representation by doing a GET on the URL.
Retrieve a representation by doing a GET on the specified URL.
Retrieve a representation by doing a GET on the URI template.
Retrieve a representation by doing a GET on the URL.
Retrieve all headers of the resource specified by the URI template.
Retrieve all headers of the resource specified by the URI template.
Retrieve all headers of the resource specified by the URL.
Return the value of the
Allow
header for the given URI.
Return the value of the
Allow
header for the given URI.
Return the value of the
Allow
header for the given URL.
Update a resource by PATCHing the given object to the URI template,
and return the representation found in the response.
Update a resource by PATCHing the given object to the URI template,
and return the representation found in the response.
Update a resource by PATCHing the given object to the URL,
and return the representation found in the response.
Create a new resource by POSTing the given object to the URI template,
and returns the response as
ResponseEntity
.
Create a new resource by POSTing the given object to the URI template,
and returns the response as
HttpEntity
.
Create a new resource by POSTing the given object to the URL,
and returns the response as
ResponseEntity
.
Create a new resource by POSTing the given object to the URI template, and returns the value of
the
Location
header.
Create a new resource by POSTing the given object to the URI template, and returns the value of
the
Location
header.
Create a new resource by POSTing the given object to the URL, and returns the value of the
Location
header.
Create a new resource by POSTing the given object to the URI template,
and returns the representation found in the response.
Create a new resource by POSTing the given object to the URI template,
and returns the representation found in the response.
Create a new resource by POSTing the given object to the URL,
and returns the representation found in the response.
Create or update a resource by PUTting the given object to the URI.
Creates a new resource by PUTting the given object to URI template.
Creates a new resource by PUTting the given object to URL.
Object
... uriVariables)
throws
RestClientException
Retrieve a representation by doing a GET on the specified URL.
The response (if any) is converted and returned.
URI Template variables are expanded using the given URI variables, if any.
Parameters:
url
- the URL
responseType
- the type of the return value
uriVariables
- the variables to expand the template
Returns:
the converted object
Throws:
RestClientException
Map
<
String
,
?> uriVariables)
throws
RestClientException
Retrieve a representation by doing a GET on the URI template.
The response (if any) is converted and returned.
URI Template variables are expanded using the given map.
Parameters:
url
- the URL
responseType
- the type of the return value
uriVariables
- the map containing variables for the URI template
Returns:
the converted object
Throws:
RestClientException
Class
<T> responseType)
throws
RestClientException
Retrieve a representation by doing a GET on the URL.
The response (if any) is converted and returned.
Parameters:
url
- the URL
responseType
- the type of the return value
Returns:
the converted object
Throws:
RestClientException
Retrieve an entity by doing a GET on the specified URL.
The response is converted and stored in a
ResponseEntity
.
URI Template variables are expanded using the given URI variables, if any.
Parameters:
url
- the URL
responseType
- the type of the return value
uriVariables
- the variables to expand the template
Returns:
the entity
Throws:
RestClientException
Since:
3.0.2
Retrieve a representation by doing a GET on the URI template.
The response is converted and stored in a
ResponseEntity
.
URI Template variables are expanded using the given map.
Parameters:
url
- the URL
responseType
- the type of the return value
uriVariables
- the map containing variables for the URI template
Returns:
the converted object
Throws:
RestClientException
Since:
3.0.2
Retrieve a representation by doing a GET on the URL.
The response is converted and stored in a
ResponseEntity
.
Parameters:
url
- the URL
responseType
- the type of the return value
Returns:
the converted object
Throws:
RestClientException
Since:
3.0.2
Retrieve all headers of the resource specified by the URI template.
URI Template variables are expanded using the given URI variables, if any.
Parameters:
url
- the URL
uriVariables
- the variables to expand the template
Returns:
all HTTP headers of that resource
Throws:
RestClientException
Retrieve all headers of the resource specified by the URI template.
URI Template variables are expanded using the given map.
Parameters:
url
- the URL
uriVariables
- the map containing variables for the URI template
Returns:
all HTTP headers of that resource
Throws:
RestClientException
Retrieve all headers of the resource specified by the URL.
Parameters:
url
- the URL
Returns:
all HTTP headers of that resource
Throws:
RestClientException
Object
... uriVariables)
throws
RestClientException
Create a new resource by POSTing the given object to the URI template, and returns the value of
the
Location
header. This header typically indicates where the new resource is stored.
URI Template variables are expanded using the given URI variables, if any.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
The body of the entity, or
request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the
MultiValueMap
can be any Object representing the body of the part,
or an
HttpEntity
representing a part with body
and headers.
Parameters:
url
- the URL
request
- the Object to be POSTed (may be
null
)
uriVariables
- the variables to expand the template
Returns:
the value for the
Location
header
Throws:
RestClientException
See Also:
HttpEntity
Map
<
String
,
?> uriVariables)
throws
RestClientException
Create a new resource by POSTing the given object to the URI template, and returns the value of
the
Location
header. This header typically indicates where the new resource is stored.
URI Template variables are expanded using the given map.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request
The body of the entity, or
request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the
MultiValueMap
can be any Object representing the body of the part,
or an
HttpEntity
representing a part with body
and headers.
Parameters:
url
- the URL
request
- the Object to be POSTed (may be
null
)
uriVariables
- the variables to expand the template
Returns:
the value for the
Location
header
Throws:
RestClientException
See Also:
HttpEntity
Object
request)
throws
RestClientException
Create a new resource by POSTing the given object to the URL, and returns the value of the
Location
header. This header typically indicates where the new resource is stored.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
The body of the entity, or
request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the
MultiValueMap
can be any Object representing the body of the part,
or an
HttpEntity
representing a part with body
and headers.
Parameters:
url
- the URL
request
- the Object to be POSTed (may be
null
)
Returns:
the value for the
Location
header
Throws:
RestClientException
See Also:
HttpEntity
Object
... uriVariables)
throws
RestClientException
Create a new resource by POSTing the given object to the URI template,
and returns the representation found in the response.
URI Template variables are expanded using the given URI variables, if any.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
The body of the entity, or
request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the
MultiValueMap
can be any Object representing the body of the part,
or an
HttpEntity
representing a part with body
and headers.
Parameters:
url
- the URL
request
- the Object to be POSTed (may be
null
)
responseType
- the type of the return value
uriVariables
- the variables to expand the template
Returns:
the converted object
Throws:
RestClientException
See Also:
HttpEntity
Map
<
String
,
?> uriVariables)
throws
RestClientException
Create a new resource by POSTing the given object to the URI template,
and returns the representation found in the response.
URI Template variables are expanded using the given map.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
The body of the entity, or
request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the
MultiValueMap
can be any Object representing the body of the part,
or an
HttpEntity
representing a part with body
and headers.
Parameters:
url
- the URL
request
- the Object to be POSTed (may be
null
)
responseType
- the type of the return value
uriVariables
- the variables to expand the template
Returns:
the converted object
Throws:
RestClientException
See Also:
HttpEntity
Class
<T> responseType)
throws
RestClientException
Create a new resource by POSTing the given object to the URL,
and returns the representation found in the response.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
The body of the entity, or
request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the
MultiValueMap
can be any Object representing the body of the part,
or an
HttpEntity
representing a part with body
and headers.
Parameters:
url
- the URL
request
- the Object to be POSTed (may be
null
)
responseType
- the type of the return value
Returns:
the converted object
Throws:
RestClientException
See Also:
HttpEntity
Object
... uriVariables)
throws
RestClientException
Create a new resource by POSTing the given object to the URI template,
and returns the response as
ResponseEntity
.
URI Template variables are expanded using the given URI variables, if any.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
The body of the entity, or
request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the
MultiValueMap
can be any Object representing the body of the part,
or an
HttpEntity
representing a part with body
and headers.
Parameters:
url
- the URL
request
- the Object to be POSTed (may be
null
)
uriVariables
- the variables to expand the template
Returns:
the converted object
Throws:
RestClientException
Since:
3.0.2
See Also:
HttpEntity
Map
<
String
,
?> uriVariables)
throws
RestClientException
Create a new resource by POSTing the given object to the URI template,
and returns the response as
HttpEntity
.
URI Template variables are expanded using the given map.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
The body of the entity, or
request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the
MultiValueMap
can be any Object representing the body of the part,
or an
HttpEntity
representing a part with body
and headers.
Parameters:
url
- the URL
request
- the Object to be POSTed (may be
null
)
uriVariables
- the variables to expand the template
Returns:
the converted object
Throws:
RestClientException
Since:
3.0.2
See Also:
HttpEntity
Class
<T> responseType)
throws
RestClientException
Create a new resource by POSTing the given object to the URL,
and returns the response as
ResponseEntity
.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
The body of the entity, or
request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the
MultiValueMap
can be any Object representing the body of the part,
or an
HttpEntity
representing a part with body
and headers.
Parameters:
url
- the URL
request
- the Object to be POSTed (may be
null
)
Returns:
the converted object
Throws:
RestClientException
Since:
3.0.2
See Also:
HttpEntity
Object
... uriVariables)
throws
RestClientException
Create or update a resource by PUTting the given object to the URI.
URI Template variables are expanded using the given URI variables, if any.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
Parameters:
url
- the URL
request
- the Object to be PUT (may be
null
)
uriVariables
- the variables to expand the template
Throws:
RestClientException
See Also:
HttpEntity
Map
<
String
,
?> uriVariables)
throws
RestClientException
Creates a new resource by PUTting the given object to URI template.
URI Template variables are expanded using the given map.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
Parameters:
url
- the URL
request
- the Object to be PUT (may be
null
)
uriVariables
- the variables to expand the template
Throws:
RestClientException
See Also:
HttpEntity
Object
request)
throws
RestClientException
Creates a new resource by PUTting the given object to URL.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
Parameters:
url
- the URL
request
- the Object to be PUT (may be
null
)
Throws:
RestClientException
See Also:
HttpEntity
Object
... uriVariables)
throws
RestClientException
Update a resource by PATCHing the given object to the URI template,
and return the representation found in the response.
URI Template variables are expanded using the given URI variables, if any.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
NOTE: The standard JDK HTTP library does not support HTTP PATCH.
You need to use the Apache HttpComponents or OkHttp request factory.
Parameters:
url
- the URL
request
- the object to be PATCHed (may be
null
)
responseType
- the type of the return value
uriVariables
- the variables to expand the template
Returns:
the converted object
Throws:
RestClientException
Since:
4.3.5
See Also:
HttpEntity
InterceptingHttpAccessor.setRequestFactory(org.springframework.http.client.ClientHttpRequestFactory)
HttpComponentsClientHttpRequestFactory
OkHttp3ClientHttpRequestFactory
Map
<
String
,
?> uriVariables)
throws
RestClientException
Update a resource by PATCHing the given object to the URI template,
and return the representation found in the response.
URI Template variables are expanded using the given map.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
NOTE: The standard JDK HTTP library does not support HTTP PATCH.
You need to use the Apache HttpComponents or OkHttp request factory.
Parameters:
url
- the URL
request
- the object to be PATCHed (may be
null
)
responseType
- the type of the return value
uriVariables
- the variables to expand the template
Returns:
the converted object
Throws:
RestClientException
Since:
4.3.5
See Also:
HttpEntity
InterceptingHttpAccessor.setRequestFactory(org.springframework.http.client.ClientHttpRequestFactory)
HttpComponentsClientHttpRequestFactory
OkHttp3ClientHttpRequestFactory
Class
<T> responseType)
throws
RestClientException
Update a resource by PATCHing the given object to the URL,
and return the representation found in the response.
The
request
parameter can be a
HttpEntity
in order to
add additional HTTP headers to the request.
NOTE: The standard JDK HTTP library does not support HTTP PATCH.
You need to use the Apache HttpComponents or OkHttp request factory.
Parameters:
url
- the URL
request
- the object to be PATCHed (may be
null
)
responseType
- the type of the return value
Returns:
the converted object
Throws:
RestClientException
Since:
4.3.5
See Also:
HttpEntity
InterceptingHttpAccessor.setRequestFactory(org.springframework.http.client.ClientHttpRequestFactory)
HttpComponentsClientHttpRequestFactory
OkHttp3ClientHttpRequestFactory
Object
... uriVariables)
throws
RestClientException
Delete the resources at the specified URI.
URI Template variables are expanded using the given URI variables, if any.
Parameters:
url
- the URL
uriVariables
- the variables to expand in the template
Throws:
RestClientException
Map
<
String
,
?> uriVariables)
throws
RestClientException
Delete the resources at the specified URI.
URI Template variables are expanded using the given map.
Parameters:
url
- the URL
uriVariables
- the variables to expand the template
Throws:
RestClientException
Delete the resources at the specified URL.
Parameters:
url
- the URL
Throws:
RestClientException
Return the value of the
Allow
header for the given URI.
URI Template variables are expanded using the given URI variables, if any.
Parameters:
url
- the URL
uriVariables
- the variables to expand in the template
Returns:
the value of the
Allow
header
Throws:
RestClientException
optionsForAllow
Return the value of the
Allow
header for the given URI.
URI Template variables are expanded using the given map.
Parameters:
url
- the URL
uriVariables
- the variables to expand in the template
Returns:
the value of the
Allow
header
Throws:
RestClientException
Return the value of the
Allow
header for the given URL.
Parameters:
url
- the URL
Returns:
the value of the
Allow
header
Throws:
RestClientException
Object
... uriVariables)
throws
RestClientException
Execute the HTTP method to the given URI template, writing the given request entity to the request, and
returns the response as
ResponseEntity
.
URI Template variables are expanded using the given URI variables, if any.
Parameters:
url
- the URL
method
- the HTTP method (GET, POST, etc)
requestEntity
- the entity (headers and/or body) to write to the request
may be
null
)
responseType
- the type to convert the response to, or
Void.class
for no body
uriVariables
- the variables to expand in the template
Returns:
the response as entity
Throws:
RestClientException
Since:
3.0.2
Map
<
String
,
?> uriVariables)
throws
RestClientException
Execute the HTTP method to the given URI template, writing the given request entity to the request, and
returns the response as
ResponseEntity
.
URI Template variables are expanded using the given URI variables, if any.
Parameters:
url
- the URL
method
- the HTTP method (GET, POST, etc)
requestEntity
- the entity (headers and/or body) to write to the request
(may be
null
)
responseType
- the type to convert the response to, or
Void.class
for no body
uriVariables
- the variables to expand in the template
Returns:
the response as entity
Throws:
RestClientException
Since:
3.0.2
Class
<T> responseType)
throws
RestClientException
Execute the HTTP method to the given URI template, writing the given request entity to the request, and
returns the response as
ResponseEntity
.
Parameters:
url
- the URL
method
- the HTTP method (GET, POST, etc)
requestEntity
- the entity (headers and/or body) to write to the request
(may be
null
)
responseType
- the type to convert the response to, or
Void.class
for no body
Returns:
the response as entity
Throws:
RestClientException
Since:
3.0.2
HttpEntity
<?> requestEntity,
ParameterizedTypeReference
<T> responseType,
Object
... uriVariables)
throws
RestClientException
Execute the HTTP method to the given URI template, writing the given
request entity to the request, and returns the response as
ResponseEntity
.
The given
ParameterizedTypeReference
is used to pass generic type information:
ParameterizedTypeReference<List<MyBean>> myBean =
new ParameterizedTypeReference<List<MyBean>>() {};
ResponseEntity<List<MyBean>> response =
template.exchange("https://example.com",HttpMethod.GET, null, myBean);
Parameters:
url
- the URL
method
- the HTTP method (GET, POST, etc)
requestEntity
- the entity (headers and/or body) to write to the
request (may be
null
)
responseType
- the type to convert the response to, or
Void.class
for no body
uriVariables
- the variables to expand in the template
Returns:
the response as entity
Throws:
RestClientException
Since:
HttpEntity
<?> requestEntity,
ParameterizedTypeReference
<T> responseType,
Map
<
String
,
?> uriVariables)
throws
RestClientException
Execute the HTTP method to the given URI template, writing the given
request entity to the request, and returns the response as
ResponseEntity
.
The given
ParameterizedTypeReference
is used to pass generic type information:
ParameterizedTypeReference<List<MyBean>> myBean =
new ParameterizedTypeReference<List<MyBean>>() {};
ResponseEntity<List<MyBean>> response =
template.exchange("https://example.com",HttpMethod.GET, null, myBean);
Parameters:
url
- the URL
method
- the HTTP method (GET, POST, etc)
requestEntity
- the entity (headers and/or body) to write to the request
(may be
null
)
responseType
- the type to convert the response to, or
Void.class
for no body
uriVariables
- the variables to expand in the template
Returns:
the response as entity
Throws:
RestClientException
Since:
HttpEntity
<?> requestEntity,
ParameterizedTypeReference
<T> responseType)
throws
RestClientException
Execute the HTTP method to the given URI template, writing the given
request entity to the request, and returns the response as
ResponseEntity
.
The given
ParameterizedTypeReference
is used to pass generic type information:
ParameterizedTypeReference<List<MyBean>> myBean =
new ParameterizedTypeReference<List<MyBean>>() {};
ResponseEntity<List<MyBean>> response =
template.exchange("https://example.com",HttpMethod.GET, null, myBean);
Parameters:
url
- the URL
method
- the HTTP method (GET, POST, etc)
requestEntity
- the entity (headers and/or body) to write to the request
(may be
null
)
responseType
- the type to convert the response to, or
Void.class
for no body
Returns:
the response as entity
Throws:
RestClientException
Since:
exchange
Execute the request specified in the given
RequestEntity
and return
the response as
ResponseEntity
. Typically used in combination
with the static builder methods on
RequestEntity
, for instance:
MyRequest body = ...
RequestEntity request = RequestEntity
.post(URI.create("https://example.com/foo"))
.accept(MediaType.APPLICATION_JSON)
.body(body);
ResponseEntity<MyResponse> response = template.exchange(request, MyResponse.class);
Parameters:
requestEntity
- the entity to write to the request
responseType
- the type to convert the response to, or
Void.class
for no body
Returns:
the response as entity
Throws:
RestClientException
Since:
exchange
Execute the request specified in the given
RequestEntity
and return
the response as
ResponseEntity
. The given
ParameterizedTypeReference
is used to pass generic type information:
MyRequest body = ...
RequestEntity request = RequestEntity
.post(URI.create("https://example.com/foo"))
.accept(MediaType.APPLICATION_JSON)
.body(body);
ParameterizedTypeReference<List<MyResponse>> myBean =
new ParameterizedTypeReference<List<MyResponse>>() {};
ResponseEntity<List<MyResponse>> response = template.exchange(request, myBean);
Parameters:
requestEntity
- the entity to write to the request
responseType
- the type to convert the response to, or
Void.class
for no body
Returns:
the response as entity
Throws:
RestClientException
Since:
ResponseExtractor
<T> responseExtractor,
Object
... uriVariables)
throws
RestClientException
Execute the HTTP method to the given URI template, preparing the request with the
RequestCallback
, and reading the response with a
ResponseExtractor
.
URI Template variables are expanded using the given URI variables, if any.
Parameters:
uriTemplate
- the URI template
method
- the HTTP method (GET, POST, etc)
requestCallback
- object that prepares the request
responseExtractor
- object that extracts the return value from the response
uriVariables
- the variables to expand in the template
Returns:
an arbitrary object, as returned by the
ResponseExtractor
Throws:
RestClientException
ResponseExtractor
<T> responseExtractor,
Map
<
String
,
?> uriVariables)
throws
RestClientException
Execute the HTTP method to the given URI template, preparing the request with the
RequestCallback
, and reading the response with a
ResponseExtractor
.
URI Template variables are expanded using the given URI variables map.
Parameters:
uriTemplate
- the URI template
method
- the HTTP method (GET, POST, etc)
requestCallback
- object that prepares the request
responseExtractor
- object that extracts the return value from the response
uriVariables
- the variables to expand in the template
Returns:
an arbitrary object, as returned by the
ResponseExtractor
Throws:
RestClientException
ResponseExtractor
<T> responseExtractor)
throws
RestClientException
Parameters:
url
- the URL
method
- the HTTP method (GET, POST, etc)
requestCallback
- object that prepares the request
responseExtractor
- object that extracts the return value from the response
Returns:
an arbitrary object, as returned by the
ResponseExtractor
Throws:
RestClientException