shareplum icon indicating copy to clipboard operation
shareplum copied to clipboard

ShareplumRequestError: Shareplum HTTP Post Failed

Open rethat opened this issue 4 years ago • 4 comments
trafficstars

I have a list with more than 5000 records on my sharepoint site. I'm having issue with shareplum when I call site.List('Projects'), anyone can help me? Thanks

Code

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

username = config.get('Username')
password = config.get('Password')

authcookie = Office365('https://mydomain.sharepoint.com', username=username, password=password).GetCookies()
site = Site('https://mydomain.sharepoint.com/sites/functions/project', version=Version.v365, authcookie=authcookie, verify_ssl=True)

sp_list = site.List('Projects') #List Projects has more than 5000 records

Error

HTTPError Traceback (most recent call last) C:\Anaconda\envs\study\lib\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

C:\Anaconda\envs\study\lib\site-packages\requests\models.py in raise_for_status(self) 940 if http_error_msg: --> 941 raise HTTPError(http_error_msg, response=self) 942

HTTPError: 500 Server Error: Internal Server Error for url: https://mydomain.sharepoint.com/sites/mysite/_api/lists/getbytitle('Projects')/RenderListDataAsStream

During handling of the above exception, another exception occurred:

ShareplumRequestError Traceback (most recent call last) in ----> 1 sp_list = site.List('Projects')

C:\Anaconda\envs\study\lib\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

C:\Anaconda\envs\study\lib\site-packages\shareplum\list.py in init(self, session, list_name, url, verify_ssl, users, huge_tree, timeout, exclude_hidden_fields, site_url) 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() 521 self.version = "v365" 522

C:\Anaconda\envs\study\lib\site-packages\shareplum\list.py in _get_schema(self) 530 'X-RequestDigest': self.contextinfo['FormDigestValue']} 531 --> 532 response = post(self._session, url=url, headers=headers, data=body, timeout=self.timeout) 533 return response.json() 534

C:\Anaconda\envs\study\lib\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://mydomain.sharepoint.com/sites/mysite/_api/lists/getbytitle('Projects')/RenderListDataAsStream

rethat avatar Dec 09 '20 09:12 rethat

You cannot pull more that 5000 items from a SharePoint site. It's a known issue with SharePoint. You should use a ListView to strategically cut down the number of items you are pulling.

jasonrollins avatar Jan 29 '21 00:01 jasonrollins

You cannot pull more that 5000 items from a SharePoint site. It's a known issue with SharePoint. You should use a ListView to strategically cut down the number of items you are pulling.

At first time, I just called site.List('Projects'), this code will pull all items of the list or only get information of the list. If it only gets information then I think it has an error in here.

I didn't call sp_list.get_list_items(view_name='ViewName')

rethat avatar Mar 17 '21 02:03 rethat

I had this issue as well, but it worked when I skipped specifying the version in the Site call.

mivicker avatar Apr 26 '21 10:04 mivicker

I had this issue as well, but it worked when I skipped specifying the version in the Site call.

Bruh, when I do this I've got anothers errors. Any help please ? image

Pikpoukoe avatar Apr 21 '22 11:04 Pikpoukoe