2017-08-08 56 views
10

我试图用SharePlum这是SharePoint一个Python模块,但是当我尝试连接到我的SharePoint,SharePlum提出了我这个错误:SharePlum错误:“无法获取用户信息列表”

Traceback (most recent call last):
File "C:/Users/me/Desktop/Sharpoint/sharpoint.py", line 13, in site = Site(sharepoint_url, auth=auth)
File "C:\Users\me\AppData\Local\Programs\Python\Python36\lib\site-packages\shareplum\shareplum.py", line 46, in init self.users = self.GetUsers()
File "C:\Users\me\AppData\Local\Programs\Python\Python36\lib\site-packages\shareplum\shareplum.py", line 207, in GetUsers raise Exception("Can't get User Info List")
Exception: Can't get User Info List

这里是我写的很短代码:

auth = HttpNtlmAuth(username, password) 
site = Site(sharepoint_url, auth=auth) 

这个错误似乎表明错误的用户名/密码,但我敢肯定的是,我有是正确的......

回答

2

我硝酸钾这不是你的问题的实际解决方案,我只会添加评论,但它太长了,所以我会作为答复发布。

我不能复制你的问题,但通过查看shareplum.py的源代码,你可以看到为什么程序会抛出错误。在shareplum.py的第196行中有if子句(if response.status_code == 200:),它检查访问您的sharepoint url的请求是否成功(比状态码200),如果请求失败(比其它状态码有问题)异常(无法获取用户信息列表)。如果你想了解更多关于你的问题的信息,请到你的shareplum.py文件(“C:\ Users \ me \ AppData \ Local \ Programs \ Python \ Python36 \ lib \ site-packages \ shareplum \ shareplum.py”)和在207行之前添加这行print('{} {} Error: {} for url: {}'.format(response.status_code, 'Client'*(400 <= response.status_code < 500) + 'Server'*(500 <= response.status_code < 600), response.reason, response.url))('raise Exception(“Can not get User Info List”)')。然后你shareplum.py应该是这样的:

# Parse Response 
    if response.status_code == 200: 
     envelope = etree.fromstring(response.text.encode('utf-8')) 
     listitems = envelope[0][0][0][0][0] 
     data = [] 
     for row in listitems: 
      # Strip the 'ows_' from the beginning with key[4:] 
      data.append({key[4:]: value for (key, value) in row.items() if key[4:]}) 

     return {'py': {i['ImnName']: i['ID']+';#'+i['ImnName'] for i in data}, 
       'sp': {i['ID']+';#'+i['ImnName'] : i['ImnName'] for i in data}} 
    else: 
     print('{} {} Error: {} for url: {}'.format(response.status_code, 'Client'*(400 <= response.status_code < 500) + 'Server'*(500 <= response.status_code < 600), response.reason, response.url)) 
     raise Exception("Can't get User Info List") 

现在只需再次运行程序,它应该打印出来,为什么它不工作。 我知道最好不要改变Python模块中的文件,但是如果你知道你改变了什么,那么就没有问题,因此当你完成时只需删除添加的行。

此外,当你找到状态代码,你可以在网上搜索,只需在谷歌输入或搜索List_of_HTTP_status_codes

0

好吧,似乎我找到了解决方案,我的问题,它是关于我给的Sharepoint网址。 如果我们举这个例子:https://www.mysharepoint.com/Your/SharePoint/DocumentLibrary
您必须删除最后一部分:/DocumentLibrary

为什么要精确地移除这部分?
事实上,当你走在SharePoint够深,你的URL看起来就像是这样的:https://www.mysharepoint.com/Your/SharePoint/DocumentLibrary/Forms/AllItems.aspx?RootFolder=%2FYour%2FSharePoint%2DocumentLibrary%2FmyPersonnalFolder&FolderCTID=0x0120008BBC54784D92004D1E23F557873CC707&View=%7BE149526D%2DFD1B%2D4BFA%2DAA46%2D90DE0770F287%7D

你可以看到小路的右边是RootFolder=%2FYour%2FSharePoint%2DocumentLibrary%2Fmy%20personnal%20folder,而不是在“正常”的URL了(如果是的话,它会像那样https://www.mysharepoint.com/Your/SharePoint/DocumentLibrary/myPersonnalFolder/)。

你必须删除的是“普通”URL的末尾,所以在这种情况下,/DocumentLibrary

所以我正确的Sharepoint URL在SharePlum输入将https://www.mysharepoint.com/Your/SharePoint/

我很新到SharePoint,所以我真的不知道,这个我正确的答案,这个问题对于其他人,可能有人谁知道Sharepoint比我更能确认?