0
서버에 JSON을 게시해야하며 서버가 다른 서버를 검색해야합니다. 나는 이것을 시도했지만 효과가 없다. 디버그 할 때 성공 또는 실패에 대한 로그가 표시되지 않습니다.AsyncHttpClient 게시 및 JSON 응답 받기
String url = "https://*******/sessions";
JSONObject requestObject = new JSONObject();
try {
requestObject.put("company", "TEST");
requestObject.put("user", "*****");
requestObject.put("secure_password", "8ce241e1ed84937ee48322b170b9b18c2");
requestObject.put("secure_device_id", "C4CA4238A0B923820DCC509A6F75849B");
} catch (JSONException e) {
e.printStackTrace();
}
// JSONObject jsonParams = new JSONObject();
// jsonParams.put("notes", "Test api support");
StringEntity entity = null;
try {
entity = new StringEntity(requestObject.toString());
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
client.post(this, url, entity, "application/json",
new AsyncHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
String res = responseBody.toString();
Log.e("response " , res);
}
@Override
public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
}
});
응답 본문은 어떻게 얻을 수 있습니까?
당신이 지금 무엇을 얻을 수 있는지 말해야합니다. 나는 당신이 그것을 실제로 잘못한 것을 볼 수 있습니다. – greenapps