In my browser follwing rest API url is working and I can see XML results.
"http://V7846EKZZJ1OJAW486D66IS7GO24XKUZ@localhost:8090/prestashop/api/products/1"
I want to call this url from Java client and get results. For that I am using RestTemplate.
String result = restTemplate.getForObject("http://V7846EKZZJ1OJAW486D66IS7GO24XKUZ@localhost:8090/prestashop/api/products/1"
, String.class);
this is giving following error,
WARNING: GET request for http://V7846EKZZJ1OJAW486D66IS7GO24XKUZ@localhost:8090/prestashop/api/products/1 resulted in 401 (Unauthorized); invoking error handler
Disconnected from the target VM, address: '127.0.0.1:49533', transport: 'socket'
org.springframework.web.client.HttpClientErrorException: 401 Unauthorized
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:88)
at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:537)
Not sure why this is happening. Can't we call URL in form username@host/appplication with RestTemplate? Or is it incorrect the way I am calling this URL with RestTemplate?
regards, -Lasith.