【问题标题】:404 when sending a POST request发送 POST 请求时出现 404
【发布时间】:2022-08-03 04:21:28
【问题描述】:

当尝试通过 requests 模块发送 post 请求时,python 会抛出 404 错误。

    \"_csrf\": _csrf,
    \"staffUnit\": \"60\",
    \"position\": \"1217\",
    \"employmentDate\": \"01.08.2022\"
}

site = \"https://umschool.tech/staff-schedule/schedule-new\"

for i in range(1):
    response = session.post(site, data=data)
    print(\"JSON Response \", response.json())

Form element on the website

Request payload

Request Headers

输出:{\'时间戳\':\'2022-08-01T11:18:51.177+00:00\',\'状态\':404,\'错误\':\'未找到\',\'消息\':\",\'路径\':\'/staffing/schedule-new\'}

我是这个话题的新手,所以我不明白为什么会这样。先感谢您。

  • 我想您需要有关 API 的更多信息。也许路径 \'/staffing/schedule-new\' 没有为 POST 请求设置。您是否尝试过使用 Postman 应用程序?
  • @Tbi,是的,我尝试使用 Postman,并且成功,也许我应该更改标题?
  • 您是否还使用 Postman 为您生成 Python 代码?

标签: python post python-requests http-status-code-404


【解决方案1】:

我发现了一个问题 - 我发送了错误的 _csrf。因此,在发布问题之前,我需要检查字段:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-25
    • 1970-01-01
    • 1970-01-01
    • 2018-08-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多