sp_list = site.List('My List Name')
data = sp_list.GetListItems('All Items', query=query)
TypeError : Argument must be bytes or unicode, got 'datetime'
2. So I used a string to pass as datetime in the query, this time it runs without any error but only extracts based on the date and ignores the time part.
I have the following issues when trying to query the SharePoint list with a DateTime variable. I have Sharepoint 2016 and Python 3.8
url= "https://myCompanySP.net/sites"
last_extract_date = datetime.datetime(2021, 3, 8, 1, 30, 0) cred = HttpNtlmAuth("domain\user","password")
site = Site(url, auth=cred, verify_ssl=False)
query = {'Where' : [('Gt', 'Modified', last_extract_date)]}
sp_list = site.List('My List Name') data = sp_list.GetListItems('All Items', query=query)
TypeError : Argument must be bytes or unicode, got 'datetime'
query = {'Where' : [('Gt', 'Modified', '2021:03:08 01:30:00')]}