Monday, January 4, 2010

Accessing SharePoint 2010 Lists using RESTful Service.

What is REST?

REpresentational State Transfer (REST). specifically the standard HTTP verbs of GET, PUT, POST, and DELETE. For example most of the MS Technology uses REST even  MS Azure Platform API’s are developed as REST API’s.

In SharePoint 2010 we can access all SharePoint List  via Restful Service.  Here is the URL to access List REST Service.

http://YourServer/SiteUrl/_vti_bin/ListData.svc. 

The Below screenshots shows my site Lists REST Service Entities.  

image

http://win-m2ircoq6iqa:44119/_vti_bin/Listdata.svc/Sreenicontacts ( REST Query to get all Contacts from SharePoint List called SreeniContacts.)

image

Accessing 20nth contact from the SreeniContacts .

http://win-m2ircoq6iqa:44119/_vti_bin/Listdata.svc/Sreenicontacts(20) ( REST Query)

image

http://win-m2ircoq6iqa:44119/_vti_bin/Listdata.svc/Sreenicontacts(20)/Fname ( REST Query for accessing Fname  only)

image

http://win-m2ircoq6iqa:44119/_vti_bin/Listdata.svc/Sreenicontacts(20)/Fname/$value ( REST Query for accessing Fname Value only)

image

The following REST query returns total number of items form the list  http://win-m2ircoq6iqa:44119/_vti_bin/Listdata.svc/Sreenicontacts/$count

image

Like Silverlight SharePoint also can cross Platform as well .

Nandri(Thanks)

SreenivasaRagavan.

11 comments:

Ali Khan said...

Thanks for posting this. Nice basic example to show the usage of REST in SharePoint 2010.

Thirumal said...

Hello,

Great post-

"The following REST query returns total number of items form the list" http://win-m2ircoq6iqa:44119/_vti_bin/Listdata.svc/Sreenicontacts/$count

When tried at our end, there seems to be a limit of returning only 1000 items from the list at one shot. How to get the complete list? or there is a limitation? Any supported way?

Chaminda Somathilaka said...

Can this be use to perform advanced activities such as uploading images or adding a list item to a list with lookup column that allows multiples ?

Unknown said...

Thanks for the info on $count. I had no idea REST could do this until someone pointed me to the blog post. Is this documented anywhere?

Unknown said...
This comment has been removed by the author.
Unknown said...
This comment has been removed by the author.
Unknown said...
This comment has been removed by the author.
Unknown said...
This comment has been removed by the author.
Unknown said...
This comment has been removed by the author.
Sachin said...

Custom fields, 'Person or Group' are not available for a list using rest service. is there any way to access custom user fields for a list using this.

nikkisa889 said...

Can I simply say what a aid to seek out somebody who really knows what theyre talking about on the internet. You undoubtedly know methods to deliver a difficulty to mild and make it important. Extra people must read this and perceive this side of the story. I cant believe youre not more popular because you undoubtedly have the gift. slots for real money