Reputation: 1
here is my code, the request from postman is ok and everything from server side is ok, but from device I'm getting 500 code internal server error, here is my code, anyone can help me please?!.
@FormUrlEncoded
@POST("api/v1/password/updatePassword")
Call<ResponseUpdatePassword> updatePassword(@Header("Authorization") String BearerToken, @FieldMap Map<String, String> fieldsMap);
public MutableLiveData<Response<ResponseUpdatePassword>> updatePassword(String token, Map<String, String> hashMap) {
webservice.updatePassword(token, hashMap).enqueue(new Callback<ResponseUpdatePassword>() {
@Override
public void onResponse(Call<ResponseUpdatePassword> call, Response<ResponseUpdatePassword> response) {
responseUpdatePassword.postValue(response);
}
@Override
public void onFailure(Call<ResponseUpdatePassword> call, Throwable t) {
call.cancel();
Log.d(TAG, "updatePassword:onFailure:" + t.getLocalizedMessage());
responseRequestFailer.postValue(true);
}
});
return responseUpdatePassword;
}
public LiveData<Response<ResponseUpdatePassword>> updatePassword(String token, String password, String password_confirmation) {
Map<String, String> hashMap = new HashMap<>();
hashMap.put("password", password);
hashMap.put("password_confirmation", password_confirmation);
return userRepository.updatePassword(token, hashMap);
}
forgetPasswordViewModel.updatePassword(token, password, password_confirmation).observe(ForgetPasswordActivity.this, this::getResponseUpdatePassword);
private void getResponseUpdatePassword(Response<ResponseUpdatePassword> response) {
endProgressLoadingDialog();
if (response != null) {
if (response.body() != null) {
Toast.makeText(this, "" + response.body().getStatus(), Toast.LENGTH_SHORT).show();
Shard.lunchLoginActivity(this);
}
} else {
Toast.makeText(this, R.string.error_occurred, Toast.LENGTH_SHORT).show();
}
}
Upvotes: 0
Views: 801
Reputation: 1195
how you send token using Bearer and also check in post man are you sending data in body or just parms or try like this one time
@POST("api/v1/password/updatePassword")
Call<ResponseUpdatePassword> updatePassword(@Header("Authorization") String BearerToken,
@Body UpdatePassword updatePassword);
make a class
public class UpdatePassword {
private String password;
private String password_confirmation;
public UpdatePassword (String password, String password_confirmation) {
this.password= password;
this.password_confirmation= password_confirmation;
}
}
and send like this
UpdatePassword updatePassword=new UpdatePassword (password,confirmPassword)
userRepository.updatePassword(token, updatePassword)
Upvotes: 0