I'm working with the SharePoint 2016 OnPremis OData Rest Api. The filter parameter is defined followings:
$filter=Art/Value eq 'aString' and year(Received) eq 2019

Art is a choice value and Received is a datetime.

baseurl = http://portal/website/subsite/_vti_bin/listdata.svc/myList

baseurl --> works
baseurl + ?$select=ID --> works
baseurl + ?$select=ID&$filter=year(Received) eq 2019 --> 401
baseurl + ?$select=ID&$filter=Art/Value eq 'aString' --> 401
baseurl + ?$select=ID&$filter=Art/Value eq 'aString' and year(Received) eq 2019 --> 401

Calls are done in Chrome and IE, so the credentials are present.
Any idea whats going on?
If e.g. I filter on an integer, it works.

Further tests:
baseUrl + ?$select=Created --> works
baseUrl + ?$select=Created&$filter=year(Created) eq 2010 --> 401

  • What is an error you are getting? can you post the exact error? And for choice, I guess you can directly use $filter=Art eq 'aString'. – Ganesh Sanap Jul 3 '19 at 9:40
  • What error? I get an 401... No, if I write $filter=Art eq 'aString' I get Operator 'eq' incompatible with operand types 'Microsoft.SharePoint.Linq.DataServiceEntity' and 'System.String' – Emaborsa Jul 3 '19 at 10:04
  • Are your examples complete? I.e. does your URL include $expand? – Mike Smith - MCT - MVP Jul 3 '19 at 17:30
  • As far as i know, the $expand is only needed for lookups, not for choices. – Emaborsa Jul 4 '19 at 6:38
  • have you solved the 401 error? – Mark L Jun 19 at 7:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.