SharePoint ListData.svc 500 Error
If you’re fighting with the SharePoint ListData.svc with an odd error:
An error occurred while processing this request.
And you are using an OData operator like endswith, you may encounter this error and be puzzled with why it works for some fields but not others.
Tried various theories — indexed column? use the column in a view? maybe error with the column? — with no love until Rob thought that it might have to do with empty values.
Turns out that the underlying implementation of ListData.svc doesn’t quite like it if you have un-set or “null” values in your text fields. So a query like this:
1 |
http://collab.dev.com/_vti_bin/ListData.svc/Test?$filter=endswith(PrimaryFaxNumber, '6481099') eq true |
Will fail if there is an item in the list with an empty value for PrimaryFaxNumber.
However, using a nullity check will fix the issue:
1 |
http://collab.dev.com/_vti_bin/ListData.svc/Test?$filter=PrimaryFaxNumber ne null and endswith(PrimaryFaxNumber, '6481099') eq true |