禁止对URL使用Python到sharepoint

2024-05-20 18:46:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我希望连接到我的公司sharepoint列表,但出于测试目的,我使用我创建的这个虚拟模板

from shareplum import Site
from requests_ntlm import HttpNtlmAuth

cred = HttpNtlmAuth('email I use to login', 'password')


site = Site('https://griffithcollege628.sharepoint.com/sites/Sharepointtest/', auth=cred)
sp_list = site.List('list name')

list_data = sp_list.GetListItems()

但当我说到这一行时:

site = Site('https://griffithcollege628.sharepoint.com/sites/Sharepointtest/', auth=cred)

我得到以下错误:

Shareplum HTTP Post Failed : 403 Client Error: Forbidden for url: https://griffithcollege628.sharepoint.com/sites/Sharepointtest//_vti_bin/lists.asmx

enter image description here


Tags: fromhttpsimportcomauthsitespsites
3条回答

请检查您用于连接的用户ID是否已添加到SharePoint网站

_vti_bin之前应该只有一个/。尝试从站点变量中删除尾随的/

我不使用python,所以我不知道这种身份验证是否有效,但我对SharePoint的了解足以证明带有双//的URL是无效的

我已经尝试了下面的方法,我能够得到列表项。 让我知道它是否有效

from shareplum import Office365, Site
from shareplum.site import Version

server_url = "https://my_page.sharepoint.com/"
site_url = server_url + "sites/my_site_name"
authcookie = Office365(server_url, username=Username,password=Password).GetCookies() #here username is my mail ID
site = Site(site_url, version=Version.v365, authcookie=authcookie)
sp_list = site.List('my_list_name')
sp_data = sp_list.GetListItems()

相关问题 更多 >