For passing Object Array on retrofit requestwe will use @FieldMap
Create Object,
public class ItemsList {
@SerializedName("id")
private int id;
@SerializedName("Amount")
private int Amount;
@SerializedName("Notes")
private String Notes;
@SerializedName("serviceId")
private int serviceId;
@SerializedName("TypeId")
private int TypeId;
}
Create Object Array,
Order.Orderitems orderitems;
Map<String, String> parms = new HashMap<String, String>();
for (int i = 0; i < orderItems.size(); i++) {
orderitems = orderItems.get(i);
parms.put("ItemsList[" + i + "][id]", String.valueOf(orderitems.getId()));
parms.put("ItemsList[" + i + "][Amount]", String.valueOf(orderitems.getAmount()));
parms.put("ItemsList[" + i + "][Notes]", "");
parms.put("ItemsList[" + i + "][serviceId]", String.valueOf(orderitems.getServiceId()));
parms.put("ItemsList[" + i + "][TypeId]", String.valueOf(orderitems.getServiceTypeId()));
}
Map<String, String> parms = new HashMap<String, String>();
for (int i = 0; i < orderItems.size(); i++) {
orderitems = orderItems.get(i);
parms.put("ItemsList[" + i + "][id]", String.valueOf(orderitems.getId()));
parms.put("ItemsList[" + i + "][Amount]", String.valueOf(orderitems.getAmount()));
parms.put("ItemsList[" + i + "][Notes]", "");
parms.put("ItemsList[" + i + "][serviceId]", String.valueOf(orderitems.getServiceId()));
parms.put("ItemsList[" + i + "][TypeId]", String.valueOf(orderitems.getServiceTypeId()));
}
API Call
@FormUrlEncoded
@POST("api/shidhin/UpdateOrder")
Call<CommonResponse> updateOrderItems(@Header("Authorization") String token, @Field("OrderId") int orderid, @FieldMap Map<String, String> parms);
@POST("api/shidhin/UpdateOrder")
Call<CommonResponse> updateOrderItems(@Header("Authorization") String token, @Field("OrderId") int orderid, @FieldMap Map<String, String> parms);
No comments:
Post a Comment