我必须将JSON发布到服务器,服务器会检索另一个。我试过这个,但它没有用。当我调试时,我从未在Success或onFailure上看到登录:
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) {
}
});
我如何获得回复正文?
答案 0 :(得分:1)
我不清楚你在问什么,但你永远不会看到答案,因为你无法将 改为 如果这不是问题,请更新您的问题,我会更新我的答案。reponseBody
转换为String res = responseBody.toString();
像String res = new String(responseBody);
这样的字符串。< / p>
$(".comment:nth-child(n+3)").slideToggle();
。