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:

web service response

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

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -