4

Error Screenshot:

Error Screenshot

Hello Everyone,

I am trying to set up a connection to SharePoint list so I can read/write data to SharePoint. Below is the following code that I have ran to form a connection using SharePlum library. I am running the same exact code as the library suggests with my credentials and url but I get this error which I can't see to find online anywhere. I would really appreciate if you can help me fix this. Thanks.

ShareplumRequestError: Shareplum HTTP Post Failed : 403 Client Error: Forbidden for url: https://abc.sharepoint.com/
from shareplum import Site
from shareplum import Office365

sharepointUsername = 'user@abc.com'
sharepointPassword = 'password!'
sharepointSite = 'https://abc.sharepoint.com/sites/MySites/'
website = 'https://abc.sharepoint.com/'

authcookie = Office365(website, username=sharepointUsername, 
             password=sharepointPassword).GetCookies()
site = Site(sharepointSite, authcookie=authcookie)
Ajit Panigrahi
  • 752
  • 10
  • 27
Vatsal Patel
  • 73
  • 1
  • 1
  • 5

1 Answers1

1

It seems that you're trying to connect to SP online. Please specify Version parameter then try it again.

site = Site('https://xxxxxx.sharepoint.com/sites/sbdev/subtest01',version=Version.v365, authcookie=authcookie)

Full Code: https://github.com/kongmengfei/sharedproject/blob/master/PythonConsole-uploadfileSPO/PythonApplication2/addDocLib.py

I have tested above demo in my SPO environment, you may have a look.

BR

Baker_Kong
  • 1,739
  • 1
  • 4
  • 9
  • 1
    Thank you for your answer, just one question; do I need to have access to my root url (https:/abc.sharepoint.com/) for this code to run? I have access to 'https://abc.sharepoint.com/sites/MySite' but not to the root url. – Vatsal Patel Jul 28 '20 at 15:05
  • That error is coming from `Office365(website, username=sharepointUsername, password=sharepointPassword).GetCookies()` not the `Site(...)` one. @VatsalPatel how did you solve it? – Krishna May 24 '21 at 08:38
  • 1
    nvm.. instead of `abc.sharepoint.com`, I'm using `abc-my.sharepoint.com`. I didn't have access to the former environment. thanks @Baker for linking your repo.. it was really helpful. – Krishna May 24 '21 at 09:52
  • this worked for me i changes abc.sharepoint.com to abc-my.sharepoint.com @BalKrishnaJha worked for me adding version too is needed – Kali Kimanzi Jul 12 '21 at 14:03