Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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="http://schemas.xmlsoap.org/soap/envelope/">    <S:Body><GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/"><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

FieldRef.name = {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.

Thanks

share|improve this question

2 Answers 2

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: http://sharepointmagazine.net/articles/writing-caml-queries-for-retrieving-list-items-from-a-sharepoint-list

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="http://schemas.xmlsoap.org/soap/envelope/">    
    <S:Body>
        <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
            <listName>{5cbc4407-3851-4e00-964a-bb7e9b430f9f}</listName>    
            <viewName></viewName>    
            <rowLimit>1000</rowLimit>    
            <webID></webID>

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

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

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

Your Answer

 
discard

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.