I am using the sharepy
and logging
to connect the sharepoint. I have used the bellow code to connect
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")
While I am passing the values into the connect function it is throwing the following error
AttributeError: 'SharePointSession' object has no attribute 'cookie'
Suppose, If I didn't pass the value as a argument that time in the terminal it will ask for the username and password after typing the it on the terminal it is working fine.
But how can I make it problematically?
I am facing the following error
Traceback (most recent call last): File "copyUpload.py", line 18, in <module> 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'
0 comments:
Post a Comment