我需要从 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)