我想把一个文件放到WebDav启用的URL。 的代码看起来是这样的:蟒蛇3得到401使用requests.put
headers = {'Authorization':'Basic', 'username': 'doc_iconx', 'password': 'doc_iconx'}
id = "SOMEID"
pw = "SOMEPW"
try:
url = 'https://mywebsite.com/Dir/'
files = {'upload_file': open(fileName, 'rb')}
r = requests.put(url,auth=HTTPDigestAuth(id,pw), files=files, headers={'User-Agent': 'Mozilla'
})
我回去:
<title>401 Unauthorized</title>
</head><body>
<h1>Unauthorized</h1>
<p>This server could not verify that you
are authorized to access the document
requested. Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.</p>
</body></html>
我知道ID /密码是好的,因为我可以使用curl
任何想法做一个放?
从我看到的情况来看,您应该使用'HTTPBasicAuth'而不是'HTTPDigestAuth'。你也提到'post',但在你的例子中你正在做一个'put'。 – sal
感谢您指出我的错字。我纠正了描述为.put。 – user3670332
尝试使用HTTPBasicAuth。现在我得到了:409客户端错误:URL冲突:https://content-qa.homedepot.com/IconX/Report/ – user3670332