【问题标题】:My patch request response me 500 Internal Server Error我的补丁请求响应我 500 Internal Server Error
【发布时间】:2022-07-25 12:58:36
【问题描述】:

我的 ViewModel 函数 patchProfileEmailAddress 函数需要 emailAddress 变量

'     

    private fun saveUserEmailChanges(email: String?) {
         profileRepository.patchProfileEmailAddress(emailAddress)
         .onEach {
         when (it) {
         is Result.Success -> {
         setLoading(false)
         emailAddress = email
         updateActionState(
         MyProfilePersonInformationASMActionState.DismissBottomSheet)
         updateActionState(MyProfilePersonInformationASMActionState.OnSuccess)}

         is Result.Error -> {
         setLoading(false)
         updateActionState(
         MyProfilePersonInformationASMActionState
         .ShowErrorMessage(it.errorResponse?.message))}
         is Result.Loading -> setLoading(true)} }
         .launchIn(viewModelScope)}'

我的片段部分

'

    var usersNewMail : String? =null

  private fun setOnClickListeners() {
    binding.apply {
        adressArrowImageView.setOnClickListener{ openBodyBottomSheet()   }
        mailArrowImageView.setOnClickListener{ clickMailArrowImageView() }
        checkOkeyImageView.setOnClickListener{ clickOkeyCheckImageView() }}}

private  fun getMailChange(){
    viewModel.saveUserEmailChanges(usersNewMail)
}

private fun clickMailArrowImageView(){
    binding.apply {
        txtEditMail.isEnabled = true
        checkOkeyImageView.isVisible = true
        mailArrowImageView.isVisible = false
    }
}

private fun clickOkeyCheckImageView(){
    binding.apply {
        txtEditMail.isEnabled = false
        checkOkeyImageView.isVisible = false
        mailArrowImageView.isVisible = true
        usersNewMail = txtEditMail.text.toString()
        getMailChange()
    }
}'

邮递员工作正常。在应用程序补丁响应 500 内部服务器错误。我的 API 需要字符串,而我正在提供字符串。

【问题讨论】:

    标签: android kotlin retrofit2 patch http-status-code-500


    【解决方案1】:

    如果它在 Postman 中工作,那么你肯定会发送错误的东西,所以无论如何你要做的第一件事就是知道你在发送什么;这可以通过多种方式完成。

    例如,如果您使用 OkHttp,则使用 interceptor 进行日志记录。 这样你就可以在 LogCat 中知道发生了什么。

    找出您要发送的内容后,如果您仍然需要帮助,只需更新您的问题,我会更新我的答案。

    【讨论】:

      猜你喜欢
      • 2015-09-15
      • 2019-10-27
      • 2018-04-18
      • 1970-01-01
      • 2020-01-11
      • 2013-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多