java.io.IOException: Server returned HTTP response code: 403 for http://www.budgetbottle.com/vivino.xml
This URL is working (returns the contents) when running by Java class main method an at local tomcat server but it is throwing error when running on the tomcat server on production machine.
The code as follows:
URL url = new URL("http://www.budgetbottle.com/vivino.xml"); HttpURLConnection urlcon = (HttpURLConnection) url.openConnection(); urlcon.addRequestProperty("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"); // System.setProperty("http.agent", ""); System.setProperty("http.agent", "Chrome"); // urlcons.setRequestProperty("Content-Language", "en-US"); // urlcons.setUseCaches(false); // urlcons.setDoInput(true); // urlcons.setDoOutput(true); I have already applied the solutions provided on the similar questions asked on this forum but no solution works.
Update:
I just noticed, the wget utility also throws the same error at the production system while no issue at the local system. Please note the options like User-Agent are used
Does it a system specific error?