我正在使用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’对象没有属性’cookie’
假设,如果我没有将值作为参数传递给终端,那么在终端上输入用户名和密码后,它会询问用户名和密码,它工作正常.
但是我怎么能让它成问题呢?
我面临以下错误
Traceback (most recent call last):
File "copyUpload.py", line 18, in
p = s.post("https://aaa.sharepoint.com/sites/Graphite/_api/web/getfolderbyserverrelativeurl('/sites/aaa/bbb/')/Files/add(url='"+fileToUpload+"',overwrite=true)", data=content, headers=headers)
File "/usr/local/lib/python3.4/dist-packages/sharepy/session.py", line 135, in post
kwargs["headers"]["Authorization"] = "Bearer " + self._redigest()
File "/usr/local/lib/python3.4/dist-packages/sharepy/session.py", line 111, in _redigest
data="", headers={"Cookie": self.cookie})
AttributeError: 'SharePointSession' object has no attribute 'cookie'