I am not getting any results when I try to filter by a calculated column/field. The calculated field returns yes/no and it displays YESes and NOs in the view on browser. But when filtered for Yes or No or 1 or 0, I get the HTTP 400 error (webpage not found). Does any one know if it supported at all?
-
does your query look something like that /_api/web/lists/getbytitle('listname')/items?$filter=field eq 1– Ahmed MahmoudCommented Jun 13, 2016 at 15:06
-
Yes it does: .../_api/web/lists/GetByTitle('Test')/items?$filter=IsNum eq 1– AamirCommented Jun 13, 2016 at 15:16
-
Try Yes instead of 1 and put it in quotes.– Ramana ViswanadhaCommented Jun 13, 2016 at 15:35
-
@Ramana, I tried that as well, no change. Can anyone of you reproduce the problem at your end. This is for an o365 site. I have a numeric column called Num and it has integer values. The calculated column IsNum has this formula in it =Num>10 . So if the Num value is greater than 10 then IsNum returns Yes, otherwise No. This is exactly what I see in the list view, but not working for the REST call– AamirCommented Jun 13, 2016 at 15:39
-
is your calculated value returned as text or number?– Ramana ViswanadhaCommented Jun 13, 2016 at 15:41
2 Answers
Make it a boolean. Tested it out on my end and this is what worked.
sitecollection/_vti_bin/ListData.svc/TestList?$filter=IsNum eq true
-
Thanks @Ramana, the thing that actually made to work was using the "_vti_bin" url format. The "_api/web" format caused errors at your end also, didn't it? Please update your answer for the benefit of others. Thank you.– AamirCommented Jun 13, 2016 at 17:14
To add to Lindgren's answer and Aamir's comment..
Using the SharePoint 2010 URI rather than the 2013 URI works for me when retrieving information from SharePoint 2013.
2010: $site + "/_vti_bin/listdata.svc/MyList()?"
2013: $site + "/_api/lists/GetByTitle('My%20List')/items?"
It's worth noting that in my experience SharePoint interacts with the data differently depending on which method is used. For example, in 2010 queries and results whitespace is trimmed from object names, whereas in 2013 queries and results whitespace is replaced by %20
or _x0020_
.
Additional info on the 2010 method: https://msdn.microsoft.com/en-us/library/ff798339.aspx