【问题标题】:what's the origin of "400 Bad Request Error " error?“400 Bad Request Error”错误的根源是什么?
【发布时间】:2020-01-02 12:52:13
【问题描述】:

我正在尝试向我的服务发送数据,以便更新其值

userController(.net)

public async Task<ActionResult<bool>> Put([ObjectIdValidator]int id, [FromBody] User User)
        {
            return await _UserService.UpdateUser(User);
        }

User.service.ts

updateUser(UserId: any, user: any) {
        return this._httpClient.put(this.userUrl + `/${userId}`, user);
    }

User.component.ts

editUser() {
        this.userService.updateUser(this.userId,user)
        .pipe(takeUntil(this.destroy$))
        .subscribe((res:any) => {
              //
            });
        });

    }

我很确定将正确的数据发送到正确的网址,但有些东西不起作用,我无法弄清楚

【问题讨论】:

  • 在调试中运行这一切时发现了什么?
  • PUT localhost:....... 400 (Bad Request) ERROR Bad Request
  • 我刚刚学会了如何使用邮递员,我发现我的问题出在哪里..感谢您的帮助
  • 问题出在哪里?这些信息有一天可能会对其他人有所帮助。
  • 邮递员显示一个错误,表明正在发送的 id 无效,即使它确实存在于我的数据库中(仍在尝试弄清楚)

标签: .net angular http put


【解决方案1】:

错误 400 应该是客户端错误。例如在这里,您可能会发送无效的用户对象。请在发送前登录用户,看看有什么问题。

【讨论】:

  • 邮递员显示一个错误,表明正在发送的 id 无效,即使它确实存在于我的数据库中(仍在尝试弄清楚)
猜你喜欢
  • 2014-12-04
  • 2013-11-09
  • 2017-09-26
  • 2019-10-22
  • 1970-01-01
  • 1970-01-01
  • 2015-08-01
相关资源
最近更新 更多