Retrieving List Data using ADO.NET Data Services/REST

ADO.NET Data Service, or REST is just like SOAP/Web Services. With ADO.NET Data Services, you retrieve Sharepoint list data (or metadata) by referencing to an HTTP URL, with optional parameters.

Say you have a list called “Population” in your Sharepoint site:
http://mysite/sites/pub

The list has two columns: Country (text) and Population (number).

Here are a few ways you can retrieve information about the lost (or other lists) from the site. The data is returned to your browser as an XML file.

http://mysite/sites/pub/_vti_bin/ListData.svc
Get a list of all list names from your site

http://mysite/sites/pub/_vti_bin/ListData.svc/$metadata
Get details of all lists from your site

http://mysite/sites/pub/_vti_bin/ListData.svc/Population
Get list items in”Population”

http://mysite/sites/pub/_vti_bin/ListData.svc/Population?$orderby=Population
Get list items in “Population”, order by “Population” column

http://mysite/sites/pub/_vti_bin/ListData.svc/Population?$top=2
Get list items in “Population”, but only return the top 2 list items.

http://mysite/sites/pub/_vti_bin/ListData.svc/Population$skip=2
Get list “Population”, but skip the first 2 list items.

http://mysite/sites/pub/_vti_bin/ListData.svc/Population?$orderby=Population&$top=2&$skip=2
Get list “Population”, order by “Population” column, but skip the first 2, and only return the top 2.

All these query are completed using the HTTP command “GET”. You can also “POST” (to create), “PUT” (to update), “DELETE” (to delete) and “MERGE”. It’s definitely worth it to buy a book on this.

Advertisements
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: