I want to post arraylist of object only specific field. I usually store all field object to post call. I don't know where should I change.
Here is my object class
public class Verify {
@SerializedName("id")
@Expose
private int id;
@SerializedName("name")
@Expose
private String name;
@SerializedName("phone")
@Expose
private String phone;
}
The API only need to post ID as parameter, and there is multiple data in array. For example :
List<Verify> ver = new Arraylist()<>;
ver.add("1", John, 62807677999);
ver.add("2", Dap, 6286753193);
ver.add("3", Keel, 62812386423);
ver.add("4", Martin, 62819823733);
API Service
@POST("https://www.mmsnusindo.com/api/ver/kunjungan/rejected")
Call<List<Verify>> verifikasiKunjunganRejected(@Header("api-key") String content_type, @Body ArrayList<Verify> modelContact);
what error I get
{"status":false,"message":"Error data validation","info":{"id":["The id field is required."]}}
this code like verification data user, so there will be multiple data in arraylist, i pick data valid or not using checkbox and then send valid or not valid using POST API.
Example successful post Request

CodePudding user response:
As in api url ?id=284213 is showing then you need to add query parameter into your call.
Try below code:
@POST("https://www.mmsnusindo.com/api/ver/kunjungan/rejected")
Call<List<Verify>> verifikasiKunjunganRejected(@Header("api-key") String content_type,
@Query("id") String id,// please check your id is int or String.
@Body ArrayList<Verify> modelContact);
CodePudding user response:
As per screenshot. body is not required. So it can be like this
@POST("https://www.mmsnusindo.com/api/ver/kunjungan/rejected")
Call<List<Verify>> verifikasiKunjunganRejected(@Header("api-key") String content_type,
@Query("id") String id;// please check your id is int or String.
