Envoyer JSON comme une requête POST au serveur par AsyncHttpClient

Je veux envoyer JSON sous la forme d'un POSTER sur mon serveur localhost avec LoopJ de AsndroidAsyncHttpt. Je suis l'aide de cette méthode:
public void post(Context context, String url, HttpEntity entity, String contentType, AsyncHttpResponseHandler responseHandler)
dans mon code mais il ne fonctionne pas. Voici mon code:

private void  loginUser() throws JSONException, UnsupportedEncodingException {
String login = textLogin.getText().toString();
String password = textPassword.getText().toString();
JSONObject jsonObject = new JSONObject();
if(Utility.isNotNull(login) && Utility.isNotNull(password)) {
jsonObject.put("username", login);
jsonObject.put("password", password);
invokeWS(jsonObject);
}
else{
Toast.makeText(getApplicationContext(), "Proszę wypełnić wszystkie pola!", Toast.LENGTH_LONG).show();
}
}
private void invokeWS(JSONObject jsonObject) throws UnsupportedEncodingException {
StringEntity entity = new StringEntity(jsonObject.toString());
AsyncHttpClient client = new AsyncHttpClient();
Log.i("SER", "http://" + Constants.address + ":" + Constants.port + "/silownia_java/rest/login/auth" + entity);
Log.i("SER", "http://" + Constants.address + ":" + Constants.port + "/silownia_java/rest/login/auth" + jsonObject);
client.post(getApplicationContext(), "http://" + Constants.address + ":" + Constants.port + "/silownia_java/rest/login/auth", entity, "application/json", new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, JSONObject obj) {
try {
Log.i("SER", "HERE!");
String login = obj.getString("login");
int ID = obj.getInt("id");
//user.setUserId(obj.getInt("userid"));
} catch (JSONException e) {
//TODO Auto-generated catch block
Toast.makeText(getApplicationContext(), "Error Occured [Server's JSON response might be invalid]!", Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
@Override
public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) {
if (statusCode == 404) {
Toast.makeText(getApplicationContext(), "404 - Nie odnaleziono serwera!", Toast.LENGTH_LONG).show();
} else if (statusCode == 500) {
Toast.makeText(getApplicationContext(), "500 - Coś poszło nie tak po stronie serwera!", Toast.LENGTH_LONG).show();
} else if (statusCode == 403) {
Toast.makeText(getApplicationContext(), "Podano niepoprawne dane!", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(), throwable.toString(), Toast.LENGTH_LONG).show();
}
}
});
}

Mon Logs semble ok:

http://MY_IP_ADDRESS:8080/silownia_java/rest/login/authorg.apache.http.entity.StringEntity@384d6a6d
http://MY_IP_ADDRESS:8080/silownia_java/rest/login/auth{"username":"barni","password":"12345"}

Mais j'obtiens cette erreur:

org.apache.http.client.HttpResponseException: Unsupported Media Type

De plus, je sais que le serveur ne peut pas faire de demande. Donc, ce que la cause pourrait être?

encore un autre localhost ... c'Est le serveur sur le périphérique?
Oui bien sûr, je l'ai changé à localhost seulement pour stackoverflow, parce que je ne voulais pas montrer mon adresse ip. Je sais que le serveur répond, parce que get demandes de travaux.
Exemple de réponse: {"login":"barni","id":"1"} mais pour autant que je sais, c'est construire avec juste le string pas de JSON, il pourrait être un problème?
Côté serveur, la réponse est construit comme ceci: return Response.status(200).entity("{\"login\":\""+user.getLogin()+"\",\"id\":\""+user.getUserId()+"\"}").build() il pourrait être un problème?
Non, parce que: de Plus, je sais que le serveur ne peut pas faire de demande ... le problème, c'est localhost, il suffit de google pour localhost+android(+émulateur)

OriginalL'auteur user3448282 | 2015-06-02