Vahid Ghadiri
Vahid Ghadiri

Reputation: 4076

url.openConnection() does not open the connection to the server

I'm going to use HttpUrlConnection for calling a WebAPI. I simply call url.OpenConnectionMethod() to open the connection, but it doesn't work. Both allowUserInteraction and client.connected values of HtpUrlConnection instance are false.

URL url = new URL("http://myserver/service/api/ads/getads");
HttpURLConnection con = (HttpURLConnection) url.openConnection();

any help would be appreciated.

Upvotes: 0

Views: 3515

Answers (1)

siegy22
siegy22

Reputation: 4413

Try this:

URL url = new URL("http://yourserver/x/y/z");
URLConnection urlConnection = url.openConnection();

if this doesn't work can I see any exceptions?

Upvotes: 1

Related Questions