Can someone tell me why the following CAML query is not filtering results? It's returning files that do not contain "/Internal/Bug 594" in their FileRef value. Thanks.

<View Scope='Recursive'>
                <FieldRef Name='FSObjType' />
                <Value Type='Text'>0</Value>
                <FieldRef Name='FileRef' />
                <Value Type='Text'>/Internal/Bug 594</Value>

And here's the code i'm using to execute this query:

CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = [the query you see above];

//IEnumerator<ClientOM.List> LibsIterate = null;
ListItemCollection tempItems = LibsIterate.Current.GetItems(camlQuery);

//ClientOM.ClientContext clientContext = null;

//List<ListItem> allItems = new List<ListItem>();
  • 1
    Try converting <Value Type='Text'> to <Value Type='URL'> Dec 5, 2012 at 14:24
  • 1
    Also instead of FileRef, try using ServerUrl field with <Value Type='Text'> Dec 5, 2012 at 14:40

2 Answers 2


Well, as you already guessed if the CAML query is not syntactically correct it will just run and return everything without applying any filters or ordering.

You don't get any exceptions and this is pretty counter-intuitive.


I think the problem is that the value of the FileRef field contains a space. Try replacing the space with %20 and see if it works.

  • 2
    sigh It's missing the <Where></Where> clause. Thanks for the suggestions guys. I guess it ignores that whole <And> clause, and just runs it as <Query></Query>.
    – Victor
    Dec 5, 2012 at 19:12
  • 3
    Please set that as an answer. And yes, when there is an issue with the query SP just returns all items. Jun 30, 2013 at 1:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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