次の方法で共有


Guest Post: Working with SharePoint 2013 REST API

Our SharePoint Server MVP Destin N Joy wrote this amazing post around Rest API of SharePoint as part of his contributions in Community Day 2014. Let’s read it together:

SharePoint 2013 introduces a Representational State Transfer (REST) service that is comparable to the existing SharePoint client object models. Now, developers can interact remotely with SharePoint data by using any technology that supports REST web requests. This means that developers can perform Create, Read, Update, and Delete (CRUD) operations from their apps for SharePoint, solutions, and client applications, using REST web technologies and standard Open Data Protocol (OData) syntax.

In this article we can see some example of accessing SharePoint list data using REST service

SharePoint 2013 adds the ability for you to remotely interact with SharePoint sites by using REST. Now, you can interact directly with SharePoint objects by using any technology that supports standard REST capabilities.

To access SharePoint resources using REST, construct a RESTful HTTP request, using the Open Data Protocol (OData) standard, which corresponds to the desired client object model API. For example:

Client object model method:

List.GetByTitle(listname)

REST endpoint:

http://server/site/_api/lists/getbytitle('listname')

The client.svc web service in SharePoint handles the HTTP request, and serves the appropriate response in either Atom or JSON (JavaScript Object Notation) format. Your client application must then parse that response. The figure below shows a high-level view of the SharePoint REST architecture.

Create a console application

From the Visual Studio IDE select a console application to start our project. Please provide a location and other details before you create the project

image

How to install JSON.NET

From the Solution explorer click on Manage NuGet Packages.You will get below screen

image

Select on Json.Net and click install

image

In this article, I am explaining you two approaches for Accessing REST service one using JSON.Net and another method using XML.

Code to Access REST Using JSON

image
REST USING XML

image

image

Comments

  • Anonymous
    August 23, 2014
    Good article.