我正在使用sharepy
和logging
连接sharepoint。我用下面的代码连接
import sharepy
import logging
SPUrl = "https://vvv.sharepoint.com"
username = "testuserb@vvvv.onmicrosoft.com"
password = "aaa@123"
s = sharepy.connect(SPUrl,username,password)
s.save()
headers = {"accept": "application/json;odata=verbose",
"content-type": "application/x-www-urlencoded; charset=UTF-8"}
fileToUpload = "copyUpload.py"
with open(fileToUpload, 'rb') as read_file:
content = read_file.read()
p = s.post("https://aaa.sharepoint.com/sites/vvv/_api/web/getfolderbyserverrelativeurl('/sites/aaa/bbb/')/Files/add(url='"+fileToUpload+"',overwrite=true)", data=content, headers=headers)
print(fileToUpload+" Uploaded in SP")
os.remove(fileToUpload)
logging.info("Uploaded file: with response file")
当我将值传递到connect函数时,它抛出以下错误
AttributeError: 'SharePointSession' object has no attribute 'cookie'
假设,如果我没有把这个值作为参数在终端中传递,那么在终端上输入它之后,它会要求输入用户名和密码,这是正常的。在
但我怎样才能解决问题呢?在
我面临以下错误
^{pr2}$
如果验证成功,库
sharepy
将存储cookie。你可以用如果验证失败,则在保存SharePoint会话之前。在
常见错误
我会检查一下页面的认证要求。在我看来,它正在寻找一个用于身份验证的cookie。通常应用程序需要一个cookie来在您进行身份验证后发布数据。在将POST请求发送到服务器之前,请尝试打印出cookie。如果它打印出一些内容,请尝试将cookie与POST请求一起发送,方法是包含一个cookie参数。在
相关问题 更多 >
编程相关推荐