Add Header Value For Spring TestRestTemplate Integration Test

Update: As of Spring Boot 1.4.0, TestRestTemplate does not extend RestTemplate anymore but still provides the same API as RestTemplate.

TestRestTemplate extends RestTemplate provides the same API as the RestTemplate, so you can use that same API for sending requests. For example:

HttpHeaders headers = new HttpHeaders();
headers.add("your_header", "its_value");
template.exchange(base, HttpMethod.GET, new HttpEntity<>(headers), Page.class);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)