0
这是帖子的Json我必须通过从Android应用程序的数据可以在任何一个请帮我无法通过POST请求发送JSON原始
{
"book":{
"details":{
"detail":[
{
"title":"Ms"
}
]
},
"contact_detail":{
"mobile_number":"9888888888"
}
},
"origin_id":"134"
}
而且我的Android代码
@Override
protected Void doInBackground(Void... params) {
HttpURLConnection urlConnection=null;
String json = null;
try {
HttpResponse response;
JSONObject jsonObject = new JSONObject();
jsonObject.accumulate("origin_id", "134");
jsonObject.accumulate("mobile_number", "9888888888");
jsonObject.accumulate("title", "Ms");
json = jsonObject.toString();
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new StringEntity(json, "UTF-8"));
httpPost.setHeader("Content-Type", "application/json");
httpPost.addHeader("Accept-Encoding", "gzip");
// httpPost.setHeader("Accept-Language", "en-US");
response = httpClient.execute(httpPost);
String sresponse = response.getEntity().toString();
Log.w("QueingSystem", json);
Log.w("QueingSystem", sresponse);
Log.w("QueingSystem", EntityUtils.toString(response.getEntity()));
}
catch (Exception e) {
Log.d("InputStream", e.getLocalizedMessage());
} finally {
/* nothing to do here */
}
return null;
}
获取错误输出 {“response”:{“code”:400,“message”:“不是有效的Json”}} 无法任何人请帮助我
'{“prop”:“val”,}'无效json不是'[“a”,“b”,]' – Selvin
检查您的Web服务服务器日志。这可能会揭示正在发生的事情。 – LoveForDroid
@LoveForDroid显示的不是有效的Json –