此处数据是带有数组的数组。 在我写的界面中
@FormUrlEncoded
@POST
Call<ResponseModel> add_to_sheet(
@HeaderMap HashMap<String, String> headers,
@Url String url,
@Field("data[]") ArrayList<ArrayList<String>> data,
@Field("insert") String insert,
@Field("sheet_id") String sheet_id,
@Field("sheet_name") String sheet_name
);
活动中
private void add_to_sheet(){
String url = "http://domainname.com/index.php";
String m_insert = "yes";
String m_sheet_id = mEdtSheetId.getText().toString();
String m_sheet_name = mEdtSheetName.getText().toString();
date = mEdtDate.getText().toString();
category = mEdtCategory.getText().toString();
amount = mEdtAmount.getText().toString();
ArrayList<ArrayList<String>> m_data = new ArrayList<ArrayList<String>>();
ArrayList<String> value = new ArrayList<>();
value.add(date);
value.add(category);
value.add(amount);
m_data.add(value);
final Call<ResponseModel> call_api = RetrofitAPI.getService().add_to_sheet(getHeader(),url, m_data, m_insert, m_sheet_id, m_sheet_name);
call_api.enqueue(new Callback<ResponseModel>() {
@Override
public void onResponse(Call<ResponseModel> call, Response<ResponseModel> response) {
if(response.body() != null){
ResponseModel response_data = response.body();
Toast.makeText(MainActivity.this, "Success!!!", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onFailure(Call<ResponseModel> call, Throwable t) {
Toast.makeText(MainActivity.this, "Error Occured", Toast.LENGTH_SHORT).show();
}
});
}
我无法请求服务器。我没有错误,所有数据都在变量中。我认为问题在于请求服务器