jasonrollins / shareplum

Pythonic SharePoint
MIT License
179 stars 96 forks source link

site.list("...") returns 400 Client Error in SharePlum 0.5.1 #119

Open divingtobi opened 4 years ago

divingtobi commented 4 years ago

site.list("name of list") returns an error in shareplum version 0.5.1. The same code works in 0.4.4:


upload_history_list = site.list("Upload History")

Traceback (most recent call last):

  File "C:\Users\USER-2\Anaconda3\lib\site-packages\shareplum\request_helper.py", line 17, in post
    response.raise_for_status()

  File "C:\Users\USER-2\Anaconda3\lib\site-packages\requests\models.py", line 941, in raise_for_status
    raise HTTPError(http_error_msg, response=self)

HTTPError: 400 Client Error: Bad Request for url: http://one.site.com/project/carb2_0/filedirectory//_api/lists/getbytitle('Upload%20History')/RenderListDataAsStream

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "<ipython-input-12-f7b74999ced2>", line 1, in <module>
    upload_history_list = site.list("Upload History")

  File "C:\Users\USER-2\Anaconda3\lib\site-packages\shareplum\site.py", line 501, in list
    site_url=self.site_url,

  File "C:\Users\USER-2\Anaconda3\lib\site-packages\shareplum\list.py", line 520, in __init__
    self.schema = self._get_schema()

  File "C:\Users\USER-2\Anaconda3\lib\site-packages\shareplum\list.py", line 532, in _get_schema
    response = post(self._session, url=url, headers=headers, data=body, timeout=self.timeout)

  File "C:\Users\USER-2\Anaconda3\lib\site-packages\shareplum\request_helper.py", line 20, in post
    raise ShareplumRequestError("Shareplum HTTP Post Failed", err)

ShareplumRequestError: Shareplum HTTP Post Failed : 400 Client Error: Bad Request for url: http://one.site.com/project/carb2_0/filedirectory//_api/lists/getbytitle('Upload%20History')/RenderListDataAsStream
jasonrollins commented 3 years ago

Are two "//" being added to your url?

divingtobi commented 3 years ago

No sure what you mean. The error was introduced between 0.5.0 and 0.5.1. I could fix it in 0.5.1 by changing line 532 in list.py:

# original:
# response = post(self._session, url=url, headers=headers, data=body, timeout=self.timeout)
response = self._session.post(url=url, headers=headers, data=body, timeout=self.timeout)

Not sure what the impact is though.

jasonrollins commented 3 years ago

Ahh, I see. Thanks for that. There is a change to the way the request library works between these two.

On Thu, Oct 8, 2020 at 1:31 AM divingtobi notifications@github.com wrote:

No sure what you mean. The error was introduced between 0.5.0 and 0.5.1. I could fix it in 0.5.1 by changing line 532 in list.py:

original:

response = post(self._session, url=url, headers=headers, data=body, timeout=self.timeout)

response = self._session.post(url=url, headers=headers, data=body, timeout=self.timeout)

Not sure what the impact is though.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jasonrollins/shareplum/issues/119#issuecomment-705361649, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOVTVTQO7XEER7MHUMESBDSJVMFHANCNFSM4QBJCRJQ .