API URL : BASE_URL/student/savestudenttestreport
METHOD : POST
PARAMETER TO PASS:
INPUT:
school_id:4
tabID:582328062112255
student_id:190
student_test_history_id:236
all_student_report: {"studentlist_id": "4",
"maths": "78",
},
{"studentlist_id": "5",
"Engish": "65",
"Science": "98"
}
OUTPUT:
{
"status": true,
"result": {
"student_test_history_id": "236",
"student_test_report": "\"studentlist_id\": \"4\",\n \"maths\": \"78\",\n \"studentlist_id\": \"4\",\n \"Engish\": \"65\",\n \"studentlist_id\": \"4\""
},
"message": "Report saved successfully!"
}
Errors:
1)
{
"status": false,
"message": "SchoolID should not empty!"
}
2)
{
"status": false,
"message": "Tablet ID should not empty!"
}
3)
{
"status": false,
"message": "Student ID should not empty!"
}
Модель класса
public class Example {
@SerializedName("school_id")
@Expose
private String schoolId;
@SerializedName("tabID")
@Expose
private String tabID;
@SerializedName("student_id")
@Expose
private String studentId;
@SerializedName("student_test_history_id")
@Expose
private String studentTestHistoryId;
@SerializedName("studentTestReports")
@Expose
private List<StudentTestReports> studentTestReports= null;
public String getSchoolId() {
return schoolId;
}
public void setSchoolId(String schoolId) {
this.schoolId = schoolId;
}
public String getTabID() {
return tabID;
}
public void setTabID(String tabID) {
this.tabID = tabID;
}
public String getStudentId() {
return studentId;
}
public void setStudentId(String studentId) {
this.studentId = studentId;
}
public String getStudentTestHistoryId() {
return studentTestHistoryId;
}
public void setStudentTestHistoryId(String studentTestHistoryId) {
this.studentTestHistoryId = studentTestHistoryId;
}
public List<StudentTestReports> getStudentTestReports() {
return studentTestReports;
}
public void setStudentTestReports(List<StudentTestReports> studentTestReports) {
this.studentTestReports = studentTestReports;
}
}
public class StudentTestReports{
@SerializedName("testId")
@Expose
private String testId;
@SerializedName("science")
@Expose
private String science;
@SerializedName("maths")
@Expose
private String maths;
public String gettestId() {
return position;
}
public void settestId(String testId) {
this.testId= testId;
}
public String getScience() {
return science;
}
public void setScience(String science) {
this.science = science;
}
public String getMaths() {
return maths;
}
public void setMaths(String maths) {
this.maths= maths;
}
}
API-вызов через модернизацию
/**
* Change Password Online
*/
@FormUrlEncoded
@POST(WebServices. FULL_REPORT)
Call<String> fullReport(@Field("school_id")String schoolId,
@Field("tabID")String tabID,
@Field("student_id")String studentId,
@Field("student_test_history_id")String studenttestHistoryID,
@Field("all_test_report")List paymentMode);
private void razorpayCallAfterPayment(String schoolId, String tabID, String studentId, String razorpayPaymentID, String paymentSuccess) {
progressDialog.show();
Call<AfterStudentTestPaymentModel> studentTestPaymentModelCall = webService.razorpayAfterPaymentSuccess(schoolId,tabID,studentId,razorpayPaymentID,paymentSuccess);
studentTestPaymentModelCall .enqueue(new Callback<AfterStudentTestPaymentModel>() {
@Override
public void onResponse(Call<AfterStudentTestPaymentModel> call, Response<AfterStudentTestPaymentModel> response) {
if (response.isSuccessful()) {
if (response.body().isStatus()) {
/*String sTestHisID=response.body().getResult().getStudentTestHistoryId();
editor.putString("pTestHisID_razor_pay", sTestHisID);
editor.commit();*/
//} else
Toasty.success(AmountCartActivity.this, ""+response.body().getMessage(), Toast.LENGTH_SHORT, true).show();
//sharePreferenceManager_addPatient.getUserLoginData(AddPatientModel.class).getResult().getPatientId().equalsIgnoreCase("");
} else
Toast.makeText(AmountCartActivity.this, "Fail Status", Toast.LENGTH_SHORT).show();
} else {
/**
*handling bad request 400 response
*/
APIError apiError = ErrorUtils.parseError(response);
Toasty.error(AmountCartActivity.this, ""+ apiError.message(), Toast.LENGTH_SHORT, true).show();
//askForLogout();
}
if (progressDialog.isShowing())
progressDialog.dismiss();
}
@Override
public void onFailure(Call<AfterStudentTestPaymentModel> call, Throwable t) {
Toasty.error(AmountCartActivity.this, "Error occurred,Please try again", Toast.LENGTH_SHORT, true).show();
if (progressDialog.isShowing())
progressDialog.dismiss();
}
});
}
Я установил значения в примере класса и StudentTestReports, у этого класса есть testId и его значения. Итак, как мне отправить эти значения с помощью массива Json через вызов Retrofit2 Api. И я хочу отправить разные значения через разные testID. Я понятия не имею об этом, поэтому, пожалуйста, помогите мне.