24

When I perform a REST query to the following URL: _api/web/lists/getbytitle('BtProjects')/items?$filter=Active eq true I receive only the one item that has this field marked as false. I get the same result when regarless of whete I use eq true or eq false. Anyone have any suggestions for a work-around? This is on prem SP1 and my understanding is that this issue does not appear on SP Online, but I've not verified that.

  • This does work just fine on SP Online; have you tried using 'true' (with the single quotes)? – John-M Aug 1 '14 at 18:51
  • 2
    I can replicate in SP Online. Filtering for field eq true or field eq 'true' returns items where field is false. – wjervis Aug 1 '14 at 19:20
41

Try using 1 for true, 0 for false. I was able to replicate your problem in SPO, but using 1/0 worked fine:

/_api/web/lists/getbytitle('BtProjects')/items?$filter=Active eq 1
  • That does indeed work! – Robert Kaucher Aug 1 '14 at 19:32
  • I was trying with 'true' & 'yes', but didn't thought about 1/0. This did the job, well done! – Alberto Oct 11 '17 at 9:20
4

I thought I had already tried Active ne false but I guess I had not. That seems to work. It looks like the eq filter is broken for booleans, though.

  • This solution works better when existing items may not have a value for the field. Not relative to the question, but a good thing to know. – jbeanky Nov 29 '16 at 12:11
  • Not broken, just uses 0/1 instead. – hamboy Oct 24 '17 at 15:29
  • @hamboy that's why the accepted answer is what it is. – Robert Kaucher Oct 27 '17 at 14:52
2

Booleans are still broken when using SharePoint Online and the REST API. As of this writing, using 1/0 and true/false do not function as expected. When I tested, it actually returned the FULL dataset and ignored my $filter parameter.

Instead, I just created a choice column (with yes/no as options) and switched to that:

/_api/web/lists/getbytitle('BtProjects')/items?$filter=Active eq 'Yes'
  • Still broken as of today as well @Jiffy – Cody Pace May 30 '18 at 13:02
  • mine worked, I have a yes/no column and I used 1/0 in the $filter – Aventus Jul 9 '18 at 7:19

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.