Posts

Showing posts from February, 2015

CRUD operation on Files using REST

In the previous post we have seen CRUD operation on SharePoint ListItems. In this post we are going to discuss about the operations on files in SharePoint Library using rest api. Starting with the creation of File class in our"RESTApiHelper" namespace. RESTApiHelper.Files = function (SiteUrl,ListName,FolderUrl) {     this.SiteUrl = SiteUrl;     this.ListName = ListName;     this.FolderUrl = FolderUrl;     Get All Files in Folder     this.GetAllFiles = function (doSuccess, doError) {         jQuery.ajax({             url: this.SiteUrl + "/_api/web/getfolderbyserverrelativeurl('" + this.FolderUrl + "')/Files",             type: "GET",             headers: {                 ...

CRUD operation on ListItem using REST

In the previous post we have seen CRUD operation on SharePoint List. In this post we are going to discuss about the operations on listitems using rest api. Starting with the creation of Items class in our"RESTApiHelper" namespace. RESTApiHelper.Items = function(SiteUrl,ListName){     this.SiteUrl = SiteUrl;     this.ListName = ListName; Get All List Items in SharePoint List         this.GetAllItems = function (doSuccess, doError) {         jQuery.ajax({             url: this.SiteUrl + "/_api/web/lists/GetByTitle('" + this.ListName + "')/items",             type: "GET",             headers: { "Accept": "application/json; odata=verbose" },             success: doSuccess,         ...

CRUD operation on SharePoint List using REST/Jquery

In the previous post we have discussed about the CRUD operations on Web object using rest/jquery. In this blog post, we'll discuss about the operations performed on sharepoint list object using REST api. Starting with the creation of List property in the "RESTApiHelper" namespace created in previous blog post. RESTApiHelper.List = function (SiteUrl,ListName) {     this.SiteUrl = SiteUrl; this.ListName = ListName; Get List and List Properties We can get the rest response for list using the url syntax involving the list name as "http://demositeurl/_api/web/lists/GetByTitle('DemoList')" or alternatively you can use the guid of the list as "http://demositeurl/_api/web/lists(guid'51925dd7-2108-481a-b1ef-4bfa4e69d48b')" this.GetList = function (doSuccess, doError) {             jQuery.ajax({                 url: SiteUrl + "/_api/web/li...

CRUD operation on Web object using REST API in SharePoint

As I've already discussed about REST API, so I'm assuming you all know the basics of REST API, for those who haven't read my last post please go through with " REST API for SharePoint ". In this blog post, we'll discuss about the operations performed on web object. Accessing properties of web using REST api is very simple. Creating JavaScript Namespace In this blog series we will use "RESTApiHelper" namespace to avoid conflict with other javascript libraries. Below is the code to create javascript namespace. var RESTApiHelper = window.RESTApiHelper || {}; Get SPWeb Properties Now we will create a property for Web in the namespace. RESTApiHelper.Web = function (SiteUrl) {     this.SiteUrl = SiteUrl; For getting spweb properties we have to build the url as " http://siteurl/_api/web". Below is the jquery code to call the url and get the response in json format. this.GetWeb = function (doSuccess, doError) {         $.aja...