Dro*_*eer 3 post request loopj
亲爱的,我正在使用Loopj并且非常喜欢它.它让我的生活更轻松.现在我想在帖子请求的正文中发布json.请检查它我做错了我的代码如下.
params.put("SaleOrderItems", mJsonArrayOfObject.toString());
params.put("CustomerReferenceNumber", "asdf");
// /*mSaleOrder.getmCustomerReferenceNo()*/);
params.put("RecordType", "HOS");
params.put("DeliveryDate", "2012-12-28T12:04:27.3553985+01:00"); // mSaleOrder.getmDeliveryDate());
params.put("SellToCustomerNumber", "user");
Run Code Online (Sandbox Code Playgroud)
然后我这样打电话.
mAsyncHttpClient.post(WEBCONSTANTS.ORDER_SERVICE_SAVE_ORDER, mParams,
new AsyncHttpResponseHandler(){};
Run Code Online (Sandbox Code Playgroud)
我收到了这个错误
{"Message":"No HTTP resource was found that matches the request URI}
Run Code Online (Sandbox Code Playgroud)
请告诉我如何使用LoopJ在post请求的正文中发送json对象数组.最好的祝福,
我想这就是你要找的东西:
String url = "<your site url>";
JSONObject jdata = new JSONObject();
try {
jdata.put("key1", val1);
jdata.put("key2", val2);
} catch (Exception ex) {
// json exception
}
StringEntity entity;
try {
entity = new StringEntity(jdata.toString());
client.post(getBaseContext(), url, entity, "application/json", new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String response) {
JSONObject res;
try {
res = new JSONObject(response);
Log.d("debug", res.getString("some_key")); // this is how you get a value out
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5438 次 |
| 最近记录: |