Ver Mensaje Individual
  #1 (permalink)  
Antiguo 29/01/2015, 10:54
el junco
 
Fecha de Ingreso: abril-2006
Mensajes: 23
Antigüedad: 18 años
Puntos: 0
java.io.IOException: Server returned HTTP response code: 403 for URL: <url>

I am trying to check if a service is available and always returns the same error:

java.io.IOException: Server returned HTTP response code: 403 for URL
Internet browsing proposed that it was necessary to indicate the "USER-AGENT" and so I did, but the error remains the same:

Código:
openConnection.addRequestProperty ("User-Agent", "Mozilla / 5.0 (Windows NT 6.1; WOW64) AppleWebKit / 537.36 (KHTML, like Gecko) Chrome / 40.0.2214.91 Safari / 537.36");
The complete code is:

Código:
 url = cadenaURL + cadenaEndpoint;
                URLConnection openConnection = new URL(url).openConnection();
                openConnection.connect();
                is = openConnection.getInputStream();
                if ("gzip".equals(openConnection.getContentEncoding())) {
                       is = new GZIPInputStream(is);
                }
and the error is in:

Código:
is = openConnection.getInputStream();
Someone could help me?

Thank You, a greeting,