SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am invoking Sharepoint's List Web services and using the getListItems() method. In particular, I am keen on specifying a CAML query because I really want it to just retrieve one item that I am specifically interested in. This I am doing by specifying a query in my XML string, in varying degrees of combinations, either by specifying the EncodedAbsUrl, the LinkFileName, the URL or the FileRef, with most results returning 0. The XML query looks like this :

<?xml version="1.0" ?><S:Envelope xmlns:S="">    <S:Body><GetListItems xmlns=""><listName>{5cbc4407-3851-4e00-964a-bb7e9b430f9f}</listName>    <viewName></viewName>    <rowLimit>1000</rowLimit>    <webID></webID>

**<query><Query><Where><Eq><FieldRef Name = "FileRef"/><Value Type = "Text">"/Shared%20Documents/Ashish/Word_feb27.doc"</Value></Eq></Where></Query></query>**

<viewFields><ViewFields><FieldRef Name="FSObjType"/><FieldRef Name="LinkFilename"/><FieldRef Name="UniqueId"/><FieldRef Name="FileRef"/><FieldRef Name="FileRef"/><FieldRef Name="EncodedAbsUrl"/><FieldRef Name="FileSizeDisplay"/><FieldRef Name="_UIVersionString"/><FieldRef Name="_owshiddenversion"/></ViewFields></viewFields></GetListItems>    </S:Body></S:Envelope>

Without the tags this Soap request does infact work, and it retrieves all the items that area available in the List. The frustration begins when i specify the query tag. In particular the Following combinations have been attempted by me = {LinkFileName, EncodedAbsUrl, URL,FileRef} and Value.type = {Text, URL}

Either they yield results with no 0 fields in it or they return internal errors. I figure, this is a syntactical issue and would rather shoot this question to you guys who have probably dunnit in the past to see where I am possibly messing it up.


share|improve this question

Remove your quotation marks around the file path. These are unnecessary.

Also, you're returning FileRef twice.

Here's a good tutorial to get you started writing CAML:

share|improve this answer
yep, removed quotation marks, but that really doesn't make a difference, and neither does mentioning FileRef twice, Sharepoint services simply ignore those OR the results are the same anyways, 0 items retrieved with the CAMl query but without it, there are list items being retrieved – user1020069 Sep 25 '12 at 18:47
They were more syntactical remarks than an actual answer to your problem. You posted about this the other day. Your best bet is to start eliminating possible error locations one at a time. First, get your query to work as you want it. Then worry about making the SOAP calls work. – RJ Cuthbertson Sep 25 '12 at 18:53
true, thanks for the syntactical remarks. Anyways, those errors have been removed and the SOAP calls are taking place if there are no CAMl query conditions, even with conditions they are happening, except that they do not match the conditions as specified. hope that helps clear things – user1020069 Sep 25 '12 at 18:59

Adding on rjcup3's answer I'd like to point out that you have two possible errors in your query, and it's the part where you have doubled <query><Query> ... </Query></query> which should be single. The same goes for the elements <viewFields><ViewFields> ... </ViewFields></viewFields>. As mentioned before, FielRef is also doubled.

enter image description here

Remove those three duplicate elements, and your query would look like this instead:

<?xml version="1.0" ?>
<S:Envelope xmlns:S="">    
        <GetListItems xmlns="">

                        <FieldRef Name = "FileRef"/>
                        <Value Type = "Text">/Shared%20Documents/Ashish/Word_feb27.doc</Value>

                <FieldRef Name="FSObjType"/>
                <FieldRef Name="LinkFilename"/>
                <FieldRef Name="UniqueId"/>
                <FieldRef Name="FileRef"/>
                <FieldRef Name="EncodedAbsUrl"/>
                <FieldRef Name="FileSizeDisplay"/>
                <FieldRef Name="_UIVersionString"/>
                <FieldRef Name="_owshiddenversion"/>

If that doesn't work, try the great tool CAML designer by Karine Bosch. It has helped me a lot when struggling with no rows from CAML queries.

share|improve this answer
The "doubling up" of the query and viewFields elements is correct for SOAP web services only. – Chloraphil Feb 19 '15 at 21:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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