-2
{
"AppId":"222",
"AdminUserId":"118",
"Data": [
{"FormId":456,
"FormFieldList":[
{"Value":"owe app","FieldId":"1727"},
{"Value":"","FieldId":"1728"}]}
],
"key":"22"
}
我想在下面的网址张贴上述JSON数据作为参数“jsonData” JSON帖子的问题: http://apptudio.com/api/OWE/SaveAllDataByForm
这是怎么了,我试图做的这样的:
JSONObject jsonParams = new JSONObject();
StringEntity entity = null;
String jsonFormData = "{\"AppId\":\"222\",\n" +
"\"AdminUserId\":\"118\", \"key\":\"22\", \"Data\":[ { \"FormId\":456,\"FormFieldList\":[ {\"Value\":\"shadek\",\"FieldId\":\"1727\"},{\"Value\":\"\",\"FieldId\":\"1728\"}] } ] }";
try {
jsonParams.put("jsonData", jsonFormData);
try {
entity = new StringEntity(jsonParams.toString());
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
} catch (JSONException e) {
e.printStackTrace();
}
AsyncHttpClient client = new AsyncHttpClient();
client.post(mContext, url, entity, "application/json", new AsyncHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
Log.d("Success.....", new String(responseBody));
}
@Override
public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
if(responseBody != null)
Log.d("Failure......", new String(responseBody));
else
Log.d("Failure....", ".............");
}
});
以下调试结果我在android系统的了:
D/Failure......﹕ [ 05-04 11:14:03.213 91: 272 D/AudioHardware ]
AudioHardware pcm playback is going to standby.
难道我从服务器获取该故障消息?或者服务器没有被请求?
什么'jsonFormData':后来我通过执行以下操作来解决呢? – greenapps
你也应该记录两个句柄的状态码。请告诉。 – greenapps
jsonFormData是第一个代码片段。 –