SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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 the Lists web service in Sharepoint 2010 and need to retrieve a single list Item only. I have the URL to the actual item and I am framing my query like this:

`<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>
<And>
<Eq>
**<FieldRef Name = "EncodedAbsUrl" >
</FieldRef><Value Type = "Text">http://sp10/Shared Documents/Ashish/Word_feb27.doc</Value></Eq>**
</And>
</Where>
</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>

However the results that I get are multiple where it really should be just retrieving one z:row.

Anybody know what's up?

share|improve this question

Your query is invalid because of the And element. It is throwing off your query and returning all the rows. This will result in all the rows being returned. Either add a second condition or remove the element.

share|improve this answer
    
yep, I just altered that....but it is still returning all the elements, apparently it did not make a difference :P – user1020069 Sep 24 '12 at 21:57
    
You will often see "extra" rows coming back when the CAML query syntax in invalid. PirateEric's suggestion to use a tool to compose the query is a good one. – Jason Weber Sep 25 '12 at 2:06

Can try debugging the CAML in BIWUG CAMLDesigner, http://sharepoint.biwug.be/CamlDesigner/CamlDesigner.application

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.