android - retrofit gives 500 internal server error when I add only one item, but postman response works fine -
i trying debug issue "http 500 internal access error" .for code shown below:
private void submitorder() { list<string> itemids = new arraylist<>(); list<integer> itemquantity = new arraylist<>(); (foodtruckitem foodtruckitem : foodtruckitemlist) { itemids.add(foodtruckitem.getitemid()); itemquantity.add(foodtruckitem.getitemquantityordered()); } if (internetconnection.checkconnection(this)) { observable<genericresponse> results = retroclient.getapiservice() .submitorder("******", "", total, "anywhere", "", "*****", itemids, itemquantity, foodtruckinfo.getfoodtruckid()); results.subscribeon(schedulers.io()).observeon(androidschedulers.mainthread()) .subscribe(new subscriber<genericresponse>() { @override public void oncompleted() { unsubscribe(); } @override public void onerror(throwable e) { toast.maketext(mycartactivity.this, e.getmessage(), toast.length_long).show(); } @override public void onnext(genericresponse response) { showordercompletefragment(); } }); } else { } }
here, happens when send webservice 2 items works fine, 1 item gives 500 internal server error. every case postman creates order
the postman response shown below:
i think need use map
itemids
, itemquantity
instead of list<string>/list<integer>
below :
define below parameter in retroclient.getapiservice().submitorder()
@fieldmap map<string, string> itemidsmap @fieldmap map<string, string> itemquantitymap
now pass itemids
, itemquantity
value below :
map<string, string> itemidsmap = new hashmap<>(); map<string, string> itemquantitymap = new hashmap<>(); string itemids = "item_id[%d]"; string itemquantity = "item_quantity[%d]"; (int = 0; < foodtruckitemlist.size(); i++) { itemidsmap.put(string.format(itemids, i), foodtruckitemlist.get(i).getitemid()); itemquantitymap.put(string.format(itemquantity, i), foodtruckitemlist.get(i).getitemquantityordered()); }
Comments
Post a Comment