shareplum
shareplum copied to clipboard
Shareplum HTTP Post Failed - 500 Server Error
I am getting this error when listing from our sharepoint domain. Anyone can help?
from shareplum import Site
from shareplum import Office365
from shareplum.site import Version
authcookie = Office365('https://domain.sharepoint.com', username='[email protected]', password='password').GetCookies()
site = Site('https://domain.sharepoint.com/sites/folder', version=Version.v365, authcookie=authcookie, verify_ssl=True)
sp_list = site.List('list name')
data = sp_list.GetListItems('All Items', rowlimit=200)
Error:
---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
~/Build/PyEnv/python3Env/lib/python3.7/site-packages/shareplum/request_helper.py in post(session, url, **kwargs)
16 response = session.post(url, **kwargs)
---> 17 response.raise_for_status()
18 return response
~/Build/PyEnv/python3Env/lib/python3.7/site-packages/requests/models.py in raise_for_status(self)
939 if http_error_msg:
--> 940 raise HTTPError(http_error_msg, response=self)
941
HTTPError: 500 Server Error: Internal Server Error for url: https://domain.sharepoint.com/sites/folder/_vti_bin/lists.asmx
During handling of the above exception, another exception occurred:
ShareplumRequestError Traceback (most recent call last)
<ipython-input-40-fa40ea3c27bd> in <module>
6 site = Site('https://domain.sharepoint.com/sites/folder', version=Version.v365, authcookie=authcookie, verify_ssl=True)
7
----> 8 sp_list = site.List('list name')
9 data = sp_list.GetListItems('All Items', rowlimit=200)
~/Build/PyEnv/python3Env/lib/python3.7/site-packages/shareplum/site.py in list(self, list_name, exclude_hidden_fields)
499 self.timeout,
500 exclude_hidden_fields=exclude_hidden_fields,
--> 501 site_url=self.site_url,
502 )
503
~/Build/PyEnv/python3Env/lib/python3.7/site-packages/shareplum/list.py in __init__(self, session, list_name, url, verify_ssl, users, huge_tree, timeout, exclude_hidden_fields, site_url)
516 exclude_hidden_fields=False, # type: bool
517 site_url=None):
--> 518 super().__init__(session, list_name, url, verify_ssl, users, huge_tree, timeout, exclude_hidden_fields, site_url)
519 self.site_url = site_url
520 self.schema = self._get_schema()
~/Build/PyEnv/python3Env/lib/python3.7/site-packages/shareplum/list.py in __init__(self, session, list_name, url, verify_ssl, users, huge_tree, timeout, exclude_hidden_fields, site_url)
50 self.regional_settings = {} # type: Dict[str, str]
51 self.server_settings = {} # type: Dict[str, str]
---> 52 self.get_list()
53 self.views = self.get_view_collection()
54 self.version = "2007"
~/Build/PyEnv/python3Env/lib/python3.7/site-packages/shareplum/list.py in get_list(self)
300 data=str(soap_request).encode("utf-8"),
301 verify=self._verify_ssl,
--> 302 timeout=self.timeout)
303
304 # Parse Response
~/Build/PyEnv/python3Env/lib/python3.7/site-packages/shareplum/request_helper.py in post(session, url, **kwargs)
18 return response
19 except requests.exceptions.RequestException as err:
---> 20 raise ShareplumRequestError("Shareplum HTTP Post Failed", err)
ShareplumRequestError: Shareplum HTTP Post Failed : 500 Server Error: Internal Server Error for url: https://domain.sharepoint.com/sites/folder/_vti_bin/lists.asmx
I'm having the same error, did the same as documented in this post to connect to my SP site
You have to replace 'list name'
with an existing list name. Please also note that the view name (in this case All Items
is language specific).
To add to janbrummer's response. Here's an example that works for me (with a few values changed obviously). The example below for "sp_list", you can get that litarlly buy using the dropdown in sharepoint once you are on the site landing page.
authcookie = Office365('https://fakecorpnamename.sharepoint.com', username='[email protected]', password='fakepassword').GetCookies() site = Site('https://fakecorpnamename.sharepoint.com/sites/BuyAndSale', authcookie=authcookie) sp_list = site.List('Autos') data = sp_list.GetListItems('All Items')