Im trying to connect to a server and than receive some data back in Json format. Here is my java code:
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet("https://my.server.com/validate/" + data);
request.setHeader("Accept", "application/json");
request.setHeader("X-AuthToken","my authorisation code");
HttpResponse response = client.execute(request);
I also have
<permission android:name="android.permission.INTERNET"></permission>
as a child of manifest (not application) in my manifest.xml
When I try to open the url in browser, I get the correct page but I dont get any data since it misses the authentication. I also have a good connection.
I've been trying to fix this for a few hours now, but I still get IOException at the line with client.execute(request)
java.net.UnknownHostException: my.server.com
Any ideas? :) Thanks!
Seems like you're missing uses-
?
<uses-permission android:name="android.permission.INTERNET" />
?
<permission>
is used to declare a new permission. Docs