4.2.8 Retrieve List Items That Satisfy Specified Criteria

The following example illustrates the exchange of messages required for a client to retrieve a collection of Employee list items whose Salary field value is greater than $100,000 from a data service using the AtomPub format.

HTTP Request:

 GET /_vti_bin/ListData.svc/Employees?$filter=Salary%20gt%20100000 HTTP/1.1
 Accept: application/atom+xml
 Host: www.contoso.com

HTTP Response:

 HTTP/1.1 200 OK
 Cache-Control: no-cache
 Content-Type: application/atom+xml;charset=utf-8
 Server: Microsoft-IIS/7.0
 SPRequestGuid: 6467cb6e-1043-4bc4-a971-f10bc94a5a48
 DataServiceVersion: 2.0;
 X-AspNet-Version: 2.0.50727
 Set-Cookie: SDA_Callback=05/01/2009 13:44:31; expires=Fri, 01-May-2009 20:54:31 GMT; path=/
 Set-Cookie: WSS_KeepSessionAuthenticated={afbe7ca4-c701-4f7d-9021-25cab947ae3f}; path=/
 X-Powered-By: ASP.NET
 MicrosoftSharePointTeamServices: 14.0.0.4006
 Date: Fri, 01 May 2009 20:44:31 GMT
 Content-Length: ###
  
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <feed xml:base="http://www.contoso.com/_vti_bin/ListData.svc/" 
   xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" 
   xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" 
   xmlns="http://www.w3.org/2005/Atom">
   <title type="text">Employees</title>
   <id>http://www.contoso.com/_vti_bin/ListData.svc/Employees</id>
   <updated>2009-05-01T20:44:32Z</updated>
   <link rel="self" title="Employees" href="Employees" />
   <entry m:etag="W/&quot;1&quot;">
     <id>http://www.contoso.com/_vti_bin/ListData.svc/Employees(4)</id>
     <title type="text">Phyllis Allen</title>
     <updated>2009-05-01T20:44:32Z</updated>
     <author>
       <name />
     </author>
     <link rel="edit" title="EmployeesItem" href="Employees(4)" />
     <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Projects" 
       type="application/atom+xml;type=feed" title="Projects" 
       href="Employees(4)/Projects" />
     <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/CreatedBy" 
       type="application/atom+xml;type=entry" title="CreatedBy" 
       href="Employees(4)/CreatedBy" />
     <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ModifiedBy" 
       type="application/atom+xml;type=entry" title="ModifiedBy" 
       href="Employees(4)/ModifiedBy" />
     <category term="Microsoft.SharePoint.DataService.EmployeesItem" 
       scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
     <content type="application/xml">
       <m:properties>
         <d:FullName>Phyllis Allen</d:FullName>
         <d:Salary m:type="Edm.Double">108000</d:Salary>
         <d:HireDate m:type="Edm.DateTime">1975-03-28T00:00:00</d:HireDate>
         <d:ID m:type="Edm.Int32">4</d:ID>
         <d:Modified m:type="Edm.DateTime">2009-05-01T13:40:08</d:Modified>
         <d:Created m:type="Edm.DateTime">2009-05-01T13:40:08</d:Created>
         <d:Owshiddenversion m:type="Edm.Int32">1</d:Owshiddenversion>
         <d:Version>1.0</d:Version>
         <d:Path>/Lists/Employees</d:Path>
       </m:properties>
     </content>
   </entry>
   <entry m:etag="W/&quot;1&quot;">
     <id>http://www.contoso.com/_vti_bin/ListData.svc/Employees(9)</id>
     <title type="text">Zachary Martin</title>
     <updated>2009-05-01T20:44:32Z</updated>
     <author>
       <name />
     </author>
     <link rel="edit" title="EmployeesItem" href="Employees(9)" />
     <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Projects" 
       type="application/atom+xml;type=feed" title="Projects" 
       href="Employees(9)/Projects" />
     <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/CreatedBy" 
       type="application/atom+xml;type=entry" title="CreatedBy" 
       href="Employees(9)/CreatedBy" />
     <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ModifiedBy" 
       type="application/atom+xml;type=entry" title="ModifiedBy" 
       href="Employees(9)/ModifiedBy" />
     <category term="Microsoft.SharePoint.DataService.EmployeesItem" 
       scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
     <content type="application/xml">
       <m:properties>
         <d:FullName>Zachary Martin</d:FullName>
         <d:Salary m:type="Edm.Double">112000</d:Salary>
         <d:HireDate m:type="Edm.DateTime">1974-08-15T00:00:00</d:HireDate>
         <d:ID m:type="Edm.Int32">9</d:ID>
         <d:Modified m:type="Edm.DateTime">2009-05-01T13:40:08</d:Modified>
         <d:Created m:type="Edm.DateTime">2009-05-01T13:40:08</d:Created>
         <d:Owshiddenversion m:type="Edm.Int32">1</d:Owshiddenversion>
         <d:Version>1.0</d:Version>
         <d:Path>/Lists/Employees</d:Path>
       </m:properties>
     </content>
   </entry>
   <entry m:etag="W/&quot;1&quot;">
     <id>http://www.contoso.com/_vti_bin/ListData.svc/Employees(10)</id>
     <title type="text">Kathleen Gill</title>
     <updated>2009-05-01T20:44:32Z</updated>
     <author>
       <name />
     </author>
     <link rel="edit" title="EmployeesItem" href="Employees(10)" />
     <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Projects" 
       type="application/atom+xml;type=feed" title="Projects" 
       href="Employees(10)/Projects" />
     <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/CreatedBy" 
       type="application/atom+xml;type=entry" title="CreatedBy" 
       href="Employees(10)/CreatedBy" />
     <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ModifiedBy" 
       type="application/atom+xml;type=entry" title="ModifiedBy" 
       href="Employees(10)/ModifiedBy" />
     <category term="Microsoft.SharePoint.DataService.EmployeesItem" 
       scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
     <content type="application/xml">
       <m:properties>
         <d:FullName>Kathleen Gill</d:FullName>
         <d:Salary m:type="Edm.Double">102000</d:Salary>
         <d:HireDate m:type="Edm.DateTime">1989-03-22T00:00:00</d:HireDate>
         <d:ID m:type="Edm.Int32">10</d:ID>
         <d:Modified m:type="Edm.DateTime">2009-05-01T13:40:08</d:Modified>
         <d:Created m:type="Edm.DateTime">2009-05-01T13:40:08</d:Created>
         <d:Owshiddenversion m:type="Edm.Int32">1</d:Owshiddenversion>
         <d:Version>1.0</d:Version>
         <d:Path>/Lists/Employees</d:Path>
       </m:properties>
     </content>
   </entry>
 </feed>