Posts

Showing posts with the label REST API SharePoint

CRUD operation on Groups using REST

In the previous post we have seen CRUD operation on SharePoint Users. In this post we are going to discuss about the operations on Groups in SharePoint Library using rest api. Starting with the creation of Groups class in our"RESTApiHelper" namespace. RESTApiHelper.Groups = function (SiteUrl) {     this.SiteUrl = SiteUrl; Get All groups in a Site         this.GetAllGroups = function (doSuccess, doError) {         jQuery.ajax({             url: this.SiteUrl + "/_api/web/sitegroups",             method: "GET",             headers: {                 "accept": "application/json; odata=verbose"             },             success: ...

CRUD operation on Folders using REST

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

CRUD operation on Users using REST

In the previous post we have seen CRUD operation on SharePoint Folders. In this post we are going to discuss about the operations on users in SharePoint Library using rest api. Starting with the creation of Users class in our"RESTApiHelper" namespace. RESTApiHelper.Users = function (SiteUrl) {     this.SiteUrl = SiteUrl; Get all users in site     this.GetAllUsers = function (doSuccess, doError) {         jQuery.ajax({             url: this.SiteUrl + "/_api/web/SiteUsers",             method: "GET",             headers: {                 "accept": "application/json; odata=verbose"             },   ...

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...

REST API for SharePoint

In SharePoint 2010, Microsoft has introduced REST API as an alternative to web services for accessing data and performing CRUD operation in SharePoint. And in 2013 version of SharePoint, REST API has evolved as a the alternative to customization using client side scripts and cross-site scripting. And REST is very useful in developing SharePoint hosted apps as in this kind of app, we can use only client side scripting( ECMA, JavaScript) and not managed code written in C#. REST API is basically uses http methods to perform CRUD operations and major task involved is creating url with headers and passing data wherever required in the body of http request. And in response we will get the result in the form of JSON object. So in this blog series I'm going to cover CRUD operation involving Web List and Libraries List Items Fields Files and Folders Users and Groups In the next blog post we will see how to perform CRUD operation involving web object. So, then stay tuned.