【问题标题】:SharePlumRequestError: SharePlum HTTP Post FailedSharePlumRequestError:SharePlum HTTP 发布失败
【发布时间】:2020-07-23 14:04:29
【问题描述】:

错误截图:

大家好,

我正在尝试建立与 SharePoint 列表的连接,以便可以将数据读/写到 SharePoint。下面是我使用 SharePlum 库运行以形成连接的以下代码。我正在运行与库使用我的凭据和 url 建议的完全相同的代码,但我收到了这个错误,我无法在任何地方在线找到。如果您能帮我解决这个问题,我将不胜感激。谢谢。

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)

【问题讨论】:

    标签: python sharepoint python-requests shared-libraries


    【解决方案1】:

    您似乎正在尝试在线连接到 SP。请指定版本参数,然后重试。

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

    完整代码: https://github.com/kongmengfei/sharedproject/blob/master/PythonConsole-uploadfileSPO/PythonApplication2/addDocLib.py

    我在我的SPO环境中测试过上面的demo,你可以看看。

    BR

    【讨论】:

    • 感谢您的回答,只有一个问题;我是否需要访问我的根 URL (https:/abc.sharepoint.com/) 才能运行此代码?我可以访问“abc.sharepoint.com/sites/MySite”,但不能访问根 url。
    • 该错误来自Office365(website, username=sharepointUsername, password=sharepointPassword).GetCookies() 而不是Site(...)。 @VatsalPatel 你是怎么解决的?
    • nvm.. 而不是abc.sharepoint.com,我使用的是abc-my.sharepoint.com。我无法访问以前的环境。感谢@Baker 链接你的回购.. 这真的很有帮助。
    • 这对我有用,我将 abc.sharepoint.com 更改为 abc-my.sharepoint.com @BalKrishnaJha 为我工作,也需要添加版本
    猜你喜欢
    • 1970-01-01
    • 2019-09-30
    • 1970-01-01
    • 1970-01-01
    • 2016-06-18
    • 1970-01-01
    • 2021-05-31
    • 2020-06-08
    • 2018-07-05
    相关资源
    最近更新 更多