我正在使用改造 2 访问 REST API 以使用原始正文插入 JSON 数据,我从服务器获得成功响应,但在响应时收到 404 错误
我想访问404错误请帮我解决这个问题
ApiUtil.getServiceClass().sendFinalCart(new ConfirmCartData(_id, sharedPrefManager.getUserID(), grandtotal,
grandquantity, DDK, payableprice, redeemQuantityModels)).enqueue(new Callback < CardAddToCart > () {
@Override
public void onResponse(Call < CardAddToCart > call, Response < CardAddToCart > response) {
if (response.isSuccessful()) {
cardAddToCart = response.body();
float result = cardAddToCart.getCartSuccess().getBalance();
float payablePrice = cardAddToCart.getCartSuccess().getPayablePrice();
float required = cardAddToCart.getCartSuccess().getRequired();
} else {
if (response.code() == 404) {
cardAddToCart = response.body();
try {
success = response.errorBody().string();
Toast.makeText(RedeemCartScreen.this, "" + success, Toast.LENGTH_SHORT).show();
} catch (IOException e) {
e.printStackTrace();
}
}
success = cardAddToCart.getSuccess();
}
}
@Override
public void onFailure(Call < CardAddToCart > call, Throwable t) {
}
});
我对 404 错误的响应是这样的。
{
"success": "not enough balance, pleace recharge ddk wallet",
"result": {
"balance": 1,
"payablePrice": 85,
"amountSaved": null,
"required": -14.555
}
}
成功响应 (200)。
{
"success": "transection successfull",
"result": {
"balance": 1,
"payablePrice": 100,
"amountSaved": 0,
"required": ""
}
}