簡體   English   中英

Android: Retrofit 500 內部服務器錯誤

[英]Android: Retrofit 500 Internal server error

這是我的代碼,來自郵遞員的請求正常,服務器端的一切正常,但是從設備我收到 500 代碼內部服務器錯誤,這是我的代碼,任何人都可以幫我嗎?!。

郵遞員身體郵遞員頭

@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();
        }
    }

您如何使用 Bearer 發送令牌並檢查郵遞員您是在正文中發送數據還是只是在 parms 中發送數據,或者像這樣嘗試一次

@POST("api/v1/password/updatePassword")
Call<ResponseUpdatePassword> updatePassword(@Header("Authorization") String BearerToken,
@Body UpdatePassword updatePassword);

上課

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;
}

}

並像這樣發送

 UpdatePassword  updatePassword=new UpdatePassword (password,confirmPassword) 
 userRepository.updatePassword(token, updatePassword)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM