I made% with a simple Visual Studio Community 2013
to register a person and receive a person, and I'm trying to consume this service with an android app, I'm emulating the application with the Web API
emulator.
Home
When it does Genymotion
it brings me an exception HttpResponse response = httpClient.execute(method);
saying that the connection to HttpHostConnectionException
was refused.
Home
The code snippet is all ok, but if you want to:
protected String doInBackground(String... params)
{
HttpClient httpClient = new DefaultHttpClient();
HttpUriRequest method = null;
Gson gson = new Gson();
try {
if (metodo.toUpperCase() == "POST")
{
HttpPost post = new HttpPost(url);
post.setEntity(new ByteArrayEntity(gson.toJson(object).getBytes()));
method = post;
method.setHeader("Content-Type", "application/json");
}
method.setHeader("Accept", "application/json");
method.setHeader("Accept-Charset", "utf-8");
HttpResponse response = httpClient.execute(method);
status = response.getStatusLine().getStatusCode();
return EntityUtils.toString(response.getEntity());
}
I have already been in the documentation and checked the localhost
part, and even changing from Emulator Networking
to localhost
it still does not work, but when I change to 10.0.2.2
it brings me that the connection has exceeded the time limit and not that it was refused.
How to proceed?