2017-08-08 107 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比我更能確認?