我想使用参数而不是JSON主体将POST发布到我的服务器API。Ion POST作为url参数而不是JSON主体Android
我可以实现这一点:
JsonObject json = new JsonObject();
json.addProperty("u_id", "XXX");
json.addProperty("emp_id", "XXX");
json.addProperty("lat", Double.toString(lat));
json.addProperty("lon", Double.toString(lon));
json.addProperty("paper", "5");
json.addProperty("plastic", "10");
json.addProperty("mode", "cash");
json.addProperty("status", "init");
Ion.with(getApplicationContext())
.load(getString(R.string.url)+"/transaction")
.setJsonObjectBody(json)
.asJsonObject()
.setCallback(new FutureCallback<JsonObject>() {
@Override
public void onCompleted(Exception e, JsonObject result) {
if (e != null) {
Toast.makeText(getBaseContext(), "Data : " + e.getStackTrace(), Toast.LENGTH_LONG).show();
} else {
runOnUiThread(new Runnable() {
@Override
public void run() {
progress.dismiss();
}
});
Toast.makeText(getBaseContext(), "Pickup added successfully! We will contact you soon.", Toast.LENGTH_LONG).show();
}
}
});
但我想实现由POST同荷兰国际集团以http://someserver.com/transaction/<u_id>/<emp_id>/22.56/88.45/5/10/cash/init
在我的服务器已准备好处理的参数。
无论如何,Koushik Dutta(@koush)这个图书馆是美好而异步的。爱它。
我已经修好了。无论如何感谢您的答案。 –