exchange

open fun <T> exchange(url: String, method: HttpMethod, requestEntity: HttpEntity<out Any>, responseType: Class<T>, urlVariables: Array<Any>): ResponseEntity<T>

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.

Return

the response as entity

Parameters

url

the URL

method

the HTTP method (GET, POST, etc.)

requestEntity

the entity (headers and/or body) to write to the request, maybe null

responseType

the type of the return value

urlVariables

the variables to expand in the template

<T>

the type of the return value

See also


open fun <T> exchange(url: String, method: HttpMethod, requestEntity: HttpEntity<out Any>, responseType: Class<T>, urlVariables: Map<String, out Any>): ResponseEntity<T>

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.

Return

the response as entity

Parameters

url

the URL

method

the HTTP method (GET, POST, etc.)

requestEntity

the entity (headers and/or body) to write to the request, maybe null

responseType

the type of the return value

urlVariables

the variables to expand in the template

<T>

the type of the return value

See also


open fun <T> exchange(url: URI, method: HttpMethod, requestEntity: HttpEntity<out Any>, responseType: Class<T>): ResponseEntity<T>

Execute the HTTP method to the given URI template, writing the given request entity to the request, and returns the response as ResponseEntity.

Return

the response as entity

Parameters

url

the URL

method

the HTTP method (GET, POST, etc.)

requestEntity

the entity (headers and/or body) to write to the request, maybe null

responseType

the type of the return value

<T>

the type of the return value

See also


open fun <T> exchange(url: String, method: HttpMethod, requestEntity: HttpEntity<out Any>, responseType: ParameterizedTypeReference<T>, urlVariables: Array<Any>): ResponseEntity<T>

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);
	

Return

the response as entity

Parameters

url

the URL

method

the HTTP method (GET, POST, etc.)

requestEntity

the entity (headers and/or body) to write to the request, maybe null

responseType

the type of the return value

urlVariables

the variables to expand in the template

<T>

the type of the return value

See also


open fun <T> exchange(url: String, method: HttpMethod, requestEntity: HttpEntity<out Any>, responseType: ParameterizedTypeReference<T>, urlVariables: Map<String, out Any>): ResponseEntity<T>

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);
	

Return

the response as entity

Parameters

url

the URL

method

the HTTP method (GET, POST, etc.)

requestEntity

the entity (headers and/or body) to write to the request, maybe null

responseType

the type of the return value

urlVariables

the variables to expand in the template

<T>

the type of the return value

See also


open fun <T> exchange(url: URI, method: HttpMethod, requestEntity: HttpEntity<out Any>, responseType: ParameterizedTypeReference<T>): ResponseEntity<T>

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);
	

Return

the response as entity

Parameters

url

the URL

method

the HTTP method (GET, POST, etc.)

requestEntity

the entity (headers and/or body) to write to the request, maybe null

responseType

the type of the return value

<T>

the type of the return value

See also


open fun <T> exchange(requestEntity: RequestEntity<out Any>, responseType: Class<T>): ResponseEntity<T>

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(new URI("https://example.com/foo")).accept(MediaType.APPLICATION_JSON).body(body);
	ResponseEntity<MyResponse> response = template.exchange(request, MyResponse.class);
	

Return

the response as entity

Parameters

requestEntity

the entity to write to the request

responseType

the type of the return value

<T>

the type of the return value

See also


open fun <T> exchange(requestEntity: RequestEntity<out Any>, responseType: ParameterizedTypeReference<T>): ResponseEntity<T>

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(new URI("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);
	

Return

the response as entity

Parameters

requestEntity

the entity to write to the request

responseType

the type of the return value

<T>

the type of the return value

See also