I'm trying to make a GET request to a ASP.NET Web API from Android. The API should return a JSON object with some users. When calling the API from the browser everything works fine, but when attempting to call from the Androind application nothing happens. I've looked into Fiddler and no requests are sent.
This is the code I use to make the call:
class GetData extends AsyncTask<String, String, String>{
@Override
protected String doInBackground(String... params){
HttpClient client = new DefaultHttpClient();
HttpResponse response;
try{
HttpGet get = new HttpGet("http://10.0.2.2:38216/api/user");
response = client.execute(get);
if(response != null){
InputStream inStream = response.getEntity().getContent();
String message = convertToString(inStream);
return message;
}
}
catch(Exception exp){
Log.d("Error message!", exp.toString());
}
return null;
}
}
Any ideas or hints on what I'm doing wrong would be appreciated!