【问题标题】:HTTP 405 when making a Python PUT request发出 Python PUT 请求时的 HTTP 405
【发布时间】:2021-03-16 22:56:09
【问题描述】:

我需要从 Python 发出 PUT 请求,并且一直收到 HTTP 405 响应代码。任何指向下面代码的指针都会很棒。

filepath = './sdfdd/sdfdsst/xxxxxxxxxrrrarara.json'
with open(filepath) as fh:
mydata = fh.read()
response = requests.put('https://asdfs.sdf.sdfds.com',
  data=mydata,                         
  auth=('Authorization', 'Api-Token dsdfdsfsdfsdf'),
  headers={'content-type':'application/json'},
  params={'file': filepath},
  allow_redirects=True
)
print(response)

【问题讨论】:

  • 你做过什么研究吗?您认为错误 405 意味着什么?
  • 是的,这确实与已更正和修复的不正确 api 端点有关。

标签: python-3.x rest python-requests


【解决方案1】:

这是由于导致此问题的 API 端点不正确。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-24
    • 1970-01-01
    • 2018-05-07
    • 2016-05-24
    • 2019-07-10
    • 1970-01-01
    相关资源
    最近更新 更多