0
我張貼的數據所有字符串爲varchar在服務器變量,但我正在逐漸凌空服務器錯誤或badnetwork性能誤差417Android的凌空SERVERERROR
我使用以下機能的研究來調用服務器,幫助我如果有錯誤。
public void signUpWS() {
avi.show();
StringRequest strReq = new StringRequest(StringRequest.Method.POST, Constants.SIGN_UP, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Snackbar.make(mainlayout, response.toString(), Snackbar.LENGTH_LONG).show();
Log.e("Responce from server", response.toString());
avi.hide();
if (!response.toString().contains("User")) {
spEdit.putString(getString(R.string.uaccount), response.toString());
spEdit.commit();
Intent intent = new Intent(SignUp.this, Products.class);
intent.putExtra(getString(R.string.uemail), Email_Address);
intent.putExtra(getString(R.string.uphone), Phone_Number);
intent.putExtra(getString(R.string.upass), Password);
startActivity(intent);
finish();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
avi.hide();
Log.e("Volley Error", error.toString());
if (error.toString().contains("NoConnectionError")) {
Snackbar.make(mainlayout, "Internet Not Available!", Snackbar.LENGTH_LONG).show();
} else {
Snackbar.make(mainlayout, "Webservice not responding!", Snackbar.LENGTH_LONG).show();
}
}
}) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json; charset=utf-8");
return headers;
}
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> data = new HashMap<String, String>();
String name[] = Name.split(" ");
String first = "", last = "";
boolean firstb = true;
for (int i = 0; i < name.length; i++) {
if (firstb) {
first += name[i];
firstb = false;
} else {
if (i == name.length - 1) {
last = name[i];
} else {
first += " ";
first += name[i];
}
}
}
data.put("FirstName", first);
data.put("LastName", last);
data.put("LoginName", Login_Name);
data.put("PrimaryEmail", Email_Address);
data.put("PrimaryPasscode", Encrypted_Password);
data.put("SecondaryPasscode", Encrypted_Password);
data.put("PhoneNumber", Phone_Number);
data.put("PrimaryCellNumber", Phone_Number);
data.put("AccountType", UserType);
data.put("ProfileRateSequence", "" + 0);
data.put("MemberShipType", "BASIC");
data.put("CityName", "null");
data.put("CountryId", "" + 0);
data.put("StateId", "" + 0);
data.put("IsVerified", "" + 1);
data.put("IsBlocked", "" + 0);
data.put("IsBlackListed", "" + 0);
data.put("IsActive", "" + 1);
data.put("IsDeleted", "" + 0);
return data;
}
};
AppController.getInstance().addToRequestQueue(strReq, REQ_TAG);
}[![The Error which i get on logcat.][1]][1]
400表示錯誤的請求,嘗試執行該請求,並在PostMan中使用完全相同的參數/頭,並查看結果如何,您可能會發現設置錯誤。 –
檢查http://stackoverflow.com/questions/21739276/android-volley-gives-me-400-error –
@LucaNicoletti是否有可能在webservices中有錯誤?或者我正在設置請求錯誤? –