Error 403 is given in response to a client from a web page or service to indicate that the server refuses to allow the requested action.
Typically, it's because the service is secured and can not be invoked as you are doing.
RestTemplate supports basic authentication for example and you could do something like this:
HttpComponentsClientHttpRequestFactory requestFactory =
(HttpComponentsClientHttpRequestFactory) restTemplate.getRequestFactory();
DefaultHttpClient httpClient = (DefaultHttpClient)
requestFactory.getHttpClient();
httpClient.getCredentialsProvider().setCredentials(
new AuthScope(host, port, AuthScope.ANY_REALM),
new UsernamePasswordCredentials("name", "pass"));
And then you could call the Rest service as follows:
restTemplate.exchange("http://localhost:8080/spring-security-rest-template/api/foos/1", HttpMethod.GET, null, Foo.class)
;
The apache dependency httpcomponents must be included in addition to the spring-mvc.
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.5</version>
</dependency>