27

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.

2
  • This does work just fine on SP Online; have you tried using 'true' (with the single quotes)?
    – John-M
    Aug 1, 2014 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, 2014 at 19:20

4 Answers 4

45

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
2
  • That does indeed work! Aug 1, 2014 at 19:32
  • I was trying with 'true' & 'yes', but didn't thought about 1/0. This did the job, well done!
    – Alberto S.
    Oct 11, 2017 at 9:20
5

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.

3
  • 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, 2016 at 12:11
  • Not broken, just uses 0/1 instead.
    – hamboy
    Oct 24, 2017 at 15:29
  • @hamboy that's why the accepted answer is what it is. Oct 27, 2017 at 14:52
3

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'
2
  • Still broken as of today as well @Jiffy
    – Cody Pace
    May 30, 2018 at 13:02
  • mine worked, I have a yes/no column and I used 1/0 in the $filter
    – Aventus
    Jul 9, 2018 at 7:19
1

I was able to get this to work using the methods described by wjervis and Robert recommended, but only when the bool field was the first filter term like below. Another thing to note is that the bool field can be null although the odata readout may show a true or false for the field.

/_api/ProjectData/Resources()?$filter=checkBool eq true & ResourceEmailAddress ne null

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.