2.3.0 • Published 6 years ago

sharepoint-rest v2.3.0

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

SharePoint REST with Angular

Build status Code Smells Bugs npm version Downloads Total Downloads

This AngularJS service helps to create a list item, get items that are already created, update or delete an item from the list using functions that automatically builds REST API query. This service also has a filter builder which helps to build OData query for filtering and fetching desired items from the list.

Install

NPM

npm install sharepoint-rest

Bower

bower install sharepoint-rest

Available Methods

MethodPurpose
getListItemsGet items from lists
createListItemCreate a new list item
updateListItemUpdate an existing list item
deleteListItemDelete an existing list item
getFromURLGet response from the provided API URL
getSiteURLGet the base URL of the site or sub-site
getFormDigestValueGet the Form Digest Value for that session

Example

Getting list items

sharepointRESTService.getListItems('list_name', filter).then(function(response) {
  console.log('Response :', response);
});

Creating a list item

sharepointRESTService.createListItem('list_name', data).then(function(response) {
  console.log('Response :', response);
});

Updating a list item

sharepointRESTService.updateListItem('list_name', data.Id, data).then(function(response) {
  console.log('Response :', response);
});

Deleting a list Item

sharepointRESTService.deleteListItem('list_name', Id).then(function(response) {
  console.log('Response :', response);
});

Getting from a URL

var url = "/_api/contextinfo";
sharepointRESTService.getFromURL(url).then(function(response) {
  console.log('Response :', response);
});

Sending Email

sharepointRESTService.sendEmail(emailObj);

emailObj can hold following keys: 1. to 2. cc 3. bcc 4. subject 5. body

Note: to, cc, bcc keys can be hold

  • string value like sankar.animation@gmail.com
  • array value like [sankar.animation@gmail.com, sankar.animation@hotmail.com]

Building filters

Following keys can be used to build OData query:

var filter = {
    select: ['field_name', 'id'],
    expand: {
        'list_name': ['field_name1', 'field_name2']
    },
    orderby: 'field_name asc/desc',
    filter: {
        'field_name': ['lt/gt/eq/ne', 'value']
    },
    top : 5,
    skip : 5
};
2.3.0

6 years ago

2.2.2

7 years ago

2.2.0

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.0

7 years ago

1.0.0

7 years ago