I am trying to make REST call to Fusion Table API . I am using spring Template for REST
When i am defining my URL as :
String URI = "https://www.googleapis.com/upload/fusiontables/v1/tables/tableid/import";
Exception :
Exception in thread "main" org.springframework.web.client.HttpClientErrorException: 401 Unauthorized
which is fine and means that its hitting google server .
But when i use :
URL :String URI = "https://www.googleapis.com/upload/fusiontables/v1/tables/tableid/import"+"&Authorization:""&Content-Type: application/octet-stream";
its throwing execption :
Exception in thread "main" org.springframework.web.client.HttpClientErrorException: 404 Not Found
Which I am not able to comprehend .
You are appending the request headers to your URL string, which is incorrect. These two headers:
Should not be added to the request URL. Instead, if your using Apache HttpComponents:
Or alternatively, with HttpUrlConnection:
Or alternatively, with Spring RestTemplate:
There’s a ton of information on Spring specific options on their documentation pages for RestTemplate and HttpEntity.