SlideShare a Scribd company logo
SharePoint Development, Training & Consulting
By
Pankaj Srivastava
Skills: SharePoint 2013, Apps Development, .Net, C#, JQuery, JSON, Javascript
Working With SharePoint 2013 App Model Using REST API-JQuery,
JSON, AJAX
Author: - Pankaj Kumar Srivastava
Contact:-pankajshrivastav6@gmail.com
Blog: - http://pshrivastavadotnet.blogspot.in/
Before we dive deep into SharePoint App Model first we have to understand the basic concept behind App
Model. Why Microsoft born a new baby and named it “App Model”??
Don’t be panic I am sure once you read my whitepaper you guys will feel comfort to create a SharePoint
Hosted App. So let’s begins the journey with me:-
Why Apps??
App for SharePoint is a stand-alone, self-contained piece of functionality that extends the features and
capabilities of a SharePoint site. Apps are targeted, lightweight, and easy-to-use, and do a great job at solving
a user need. Apps will be executed outside the SharePoint Server, and in the Client machine or in the
Cloud. This makes Apps makes easier installation& cleanup.
In short it is just like ready to use plug-in in SharePoint.
Types of Apps in SharePoint 2013:-
1. SharePoint Hosted: SharePoint-hosted apps contain only declarative content, such as HTML and
JavaScript, and don’t have any server-side code that is packaged with them. SharePoint-hosted apps
interact with SharePoint via the JavaScript object model or Representational State Transfer (REST)
end-points and are client-side based. The design and interaction of these types of apps are similar to
client-side design patterns used with sandboxed solutions.
2. Provider Hosted: A Provider-hosted app is one that has server-side components. These components
are usually contained within an ASP.NET application and you have to provide a separate environment
to host them. These server-side pieces can be developed in any technology as long as you can
leverage OAuth and make REST calls.
3. Auto-Hosted: This new type of app only relates to Office 365 and SharePoint Online. It has server-side
components similar to Provider-Hosted Apps. What makes it unique is that it not only provisions the
app in SharePoint, but also automatically provisions components into Azure.
Where my apps deployed?
Two Birds come into picture if you talk about deployment
 App Web: - The special website to which the app is deployed is called an app web, the app for
SharePoint components and content, such as lists, content types, workflows, and pages, are deployed
to a different website in a special isolated domain.
 Host Web:-The website to which the app is installed is called the host web
http://app-bdf2016ea7dacb.abcapps.com/sites/TestPankaj/EmployeeManagment
https:// App_Prefix App_ID . App_Base_Domain / Domain_Relative_URL_of_Host_Web / App_Na
me
Lets Understand How REST actually work and What is ODATA?
ODATA:-The Open Data Protocol (OData) is a Web protocol for querying and updating data
How to create or consume the Open Data Protocol?
OData defines a standard syntax which defines how resource representations (entities) are queried via a
Restful URI: ex {http://site url/_api/web/lists}
ODATA Restful Service:-
SharePoint 2013 Rest API service Access Point basic understanding:-
Site :-http: //server/site/_api/site
Web:-http: //server/site/_api/web
User Profile:-http: // server/site/_api/SP.UserProfiles.PeopleManager
Search:-http: // server/site/_api/search
Publishing: - http:// server/site/_api/publishing
So if once you are familiar with REST API SharePoint 2013 you would like to do more with REST so let’s dive
deep.
ODATA - SharePoint 2013 REST API Query Operators
$select - Specifies which fields are included in the returned data.
EX:-http://abc-sharepoint.com/Test/ _api/web/lists/getByTitle ('Employee')/items? $select=Title, EmpID
$filter - Specifies which members of a collection, such as the items in a list, are returned.
Ex.:-http://abc-sharepoint.com/Test /_api/web/lists/getByTitle('Employee')/items?$filter=EMPID eq '123‘
$expand: - Specifies which projected fields from a joined list are returned.
$top- Returns only the first n items of a collection or list.
http://abc-sharepoint.com/Test _api/web/lists/getByTitle( Employee)/items?$select=Title&$filter=Title eq
‘Pankaj'&$top=2
$skip: - Skips the first n items of a collection or list and returns the rest.
_api/web/lists/getbytitle('Employee')/items?$skip=100&$top=100
$orderby: - Specifies the field that’s used to sort the data before it’s returned
http://abc-sharepoint.com/Test _api/web/lists/getByTitle( Employee)/items? orderby =EMPID
Logical Query with ODATA SharePoint 2013 REST API:-
ODATA SharePoint 2013 REST API String Functions :-
ODATA SharePoint 2013 REST API Date/Math/Type Functions:-
CRUD - Creating, Reading, Updating and Deleting Entries SharePoint
2013 Using REST API
Let’s understand some basic method which is used while CRUD Operation:
GET: Get a collection of entries (read)
POST: Create a new entry from an entry document (insert).
MERGE: Update an existing entry with an entry document.
DELETE: Remove an entry.
So I have one list in my App I named it Employee and it will be located at AppWeb after deployment as I
discuss above.
Important:-
 The _spPageContextInfo JavaScript object has been around since SharePoint 2007. It provides really
easy way to start building the correct _api URI,
 The point of note here is that the odata=verbose appended to the end is required in order for the
service call to succeed.
Examples GET Method:-
Get List Items Form SharePoint List Using REST API with Ajax.
$.ajax(
{
url: _spPageContextInfo.webServerRelativeUrl +
"/_api/web/lists/getByTitle('Employee')/items/",
type: "GET",
headers: {
"accept": "application/json;odata=verbose",
},
success: function (data) {
// so once Service called Successfully it will return data in json format.
If(data.d.results.length>0)
{
//Foreach loop
$.each(data.d.results, function (i, item) {
“<table><tr><td>”+ data.d.results[i].Title +”</td></tr></table>”
});
}
},
error: function (err) {
console.log(JSON.stringify(err));
}
});
Example POST Method:-
Add an Item in SharePoint List Using POST Method.
var postitem = {
"__metadata": {
"type": SP.Data.EmployeeListItem
},
"Title": “Pankaj”,
"EMPID”:”51446959”,
"Comments": “Test Commnets”,
};
$.ajax({
url: _spPageContextInfo.webServerRelativeUrl +
"/_api/web/lists/getByTitle('Employee')/items",
type: "POST",
contentType: "application/json;odata=verbose",
data: postitem,
headers: {
"accept": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
},
success: function () {
alert(“An Item Added SuccessFully”);
},
error: function (err) {
console.log(JSON.stringify(err));
}
});
 The important thing to understand is that you must send the form digest along with any POST request
or nothing will get updated
 form digest is stored as the value of a well known element on the page: the element with id
‘__REQUESTDIGEST’
 It must be passed as the value of the X-RequestDigest header, It must be passed as the value of the X-
RequestDigest header.
 __metadata 'type' property with the list item entity type of the list.
Examples DELETE Method:-
Delete an item from list Using DELETE Method.
$.ajax(
{
url: _spPageContextInfo.webServerRelativeUrl +
"/_api/web/lists/getByTitle('Employee')/items('1234')",
type: "DELETE",
headers: {
"accept": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"IF-MATCH": "*"
},
success: function (data) {
alert(‘Item Deleted successfully’);
},
error: function (err) {
console.log(JSON.stringify(err));
}
}
);
Examples MERGE Method:-
Update an existing item from list Using MERGE Method.
var Updateitem = {
"__metadata": {
"type": SP.Data.EmployeeListItem
},
"Title": “Pankaj Kumar Srivastav”,
"EMPID”:”51446959”,
"Comments": “ My Updated Test Commnets”,
};
$.ajax(
{
url: _spPageContextInfo.webServerRelativeUrl +
"/_api/web/lists/getByTitle('Employee')/items('1234')",
type: "POST",
contentType: "application/json;odata=verbose",
data: Updateitem,
headers: {
"accept": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"X-HTTP-Method": "MERGE",
"IF-MATCH": "*"
},
success: function () {
alert(‘Item Upodated Successfully’);
},
error: function (err) {
console.log(JSON.stringify(err));
}
}
I Hope this will help you a lot to develop a New SharepointHostedApp Using REST API in SharePoint
2013/Office 365.
You have to be good knowledge in Javascript, Jquery, and JSON before Start Development on SharePoint
Hosted App Model or AppPart.
If you have any Doubt let me drop a mail: - pankajshrivastav6@gmail.com
(Pankaj Kumar Srivastava)

More Related Content

What's hot

Understanding and programming the SharePoint REST API
Understanding and programming the SharePoint REST APIUnderstanding and programming the SharePoint REST API
Understanding and programming the SharePoint REST API
Chris Beckett
 
SharePoint 2010 Application Development Overview
SharePoint 2010 Application Development OverviewSharePoint 2010 Application Development Overview
SharePoint 2010 Application Development OverviewRob Windsor
 
SharePoint 2010 Client-side Object Model
SharePoint 2010 Client-side Object ModelSharePoint 2010 Client-side Object Model
SharePoint 2010 Client-side Object ModelPhil Wicklund
 
Advanced SharePoint Web Part Development
Advanced SharePoint Web Part DevelopmentAdvanced SharePoint Web Part Development
Advanced SharePoint Web Part Development
Rob Windsor
 
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...SharePoint Saturday NY
 
[SharePoint Korea Conference 2013 / 강율구] Sharepoint 스마트하게 개발하기
[SharePoint Korea Conference 2013 / 강율구] Sharepoint 스마트하게 개발하기[SharePoint Korea Conference 2013 / 강율구] Sharepoint 스마트하게 개발하기
[SharePoint Korea Conference 2013 / 강율구] Sharepoint 스마트하게 개발하기lanslote
 
SharePoint Client Object Model (CSOM)
SharePoint Client Object Model (CSOM)SharePoint Client Object Model (CSOM)
SharePoint Client Object Model (CSOM)
Kashif Imran
 
Introduction to the SharePoint Client Object Model and REST API
Introduction to the SharePoint Client Object Model and REST APIIntroduction to the SharePoint Client Object Model and REST API
Introduction to the SharePoint Client Object Model and REST API
Rob Windsor
 
Share point review qustions
Share point review qustionsShare point review qustions
Share point review qustions
than sare
 
SharePoint 2010 Client Object Model
SharePoint 2010 Client Object ModelSharePoint 2010 Client Object Model
SharePoint 2010 Client Object Model
G. Scott Singleton
 
Power Automate Techniques that "Saved Our Bacon"
Power Automate Techniques that "Saved Our Bacon"Power Automate Techniques that "Saved Our Bacon"
Power Automate Techniques that "Saved Our Bacon"
Thomas Duff
 
Integrating SharePoint 2010 and Visual Studio Lightswitch
Integrating SharePoint 2010 and Visual Studio LightswitchIntegrating SharePoint 2010 and Visual Studio Lightswitch
Integrating SharePoint 2010 and Visual Studio LightswitchRob Windsor
 
Standards of rest api
Standards of rest apiStandards of rest api
Standards of rest api
Maýur Chourasiya
 
Hypermedia APIs
Hypermedia APIsHypermedia APIs
Hypermedia APIs
Paulo Gandra de Sousa
 
SharePoint 2010 Enterprise Search
SharePoint 2010 Enterprise SearchSharePoint 2010 Enterprise Search
SharePoint 2010 Enterprise SearchAgnes Molnar
 
Drupal and Apache Solr Search Go Together Like Pizza and Beer for Your Site
Drupal and Apache Solr Search Go Together Like Pizza and Beer for Your SiteDrupal and Apache Solr Search Go Together Like Pizza and Beer for Your Site
Drupal and Apache Solr Search Go Together Like Pizza and Beer for Your Site
nyccamp
 
Introduction To REST
Introduction To RESTIntroduction To REST
Introduction To REST
rainynovember12
 
Building Beautiful REST APIs in ASP.NET Core
Building Beautiful REST APIs in ASP.NET CoreBuilding Beautiful REST APIs in ASP.NET Core
Building Beautiful REST APIs in ASP.NET Core
Stormpath
 
Programming web application
Programming web applicationProgramming web application
Programming web applicationaspnet123
 
Charla desarrollo de apps con sharepoint y office 365
Charla   desarrollo de apps con sharepoint y office 365Charla   desarrollo de apps con sharepoint y office 365
Charla desarrollo de apps con sharepoint y office 365
Luis Valencia
 

What's hot (20)

Understanding and programming the SharePoint REST API
Understanding and programming the SharePoint REST APIUnderstanding and programming the SharePoint REST API
Understanding and programming the SharePoint REST API
 
SharePoint 2010 Application Development Overview
SharePoint 2010 Application Development OverviewSharePoint 2010 Application Development Overview
SharePoint 2010 Application Development Overview
 
SharePoint 2010 Client-side Object Model
SharePoint 2010 Client-side Object ModelSharePoint 2010 Client-side Object Model
SharePoint 2010 Client-side Object Model
 
Advanced SharePoint Web Part Development
Advanced SharePoint Web Part DevelopmentAdvanced SharePoint Web Part Development
Advanced SharePoint Web Part Development
 
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
 
[SharePoint Korea Conference 2013 / 강율구] Sharepoint 스마트하게 개발하기
[SharePoint Korea Conference 2013 / 강율구] Sharepoint 스마트하게 개발하기[SharePoint Korea Conference 2013 / 강율구] Sharepoint 스마트하게 개발하기
[SharePoint Korea Conference 2013 / 강율구] Sharepoint 스마트하게 개발하기
 
SharePoint Client Object Model (CSOM)
SharePoint Client Object Model (CSOM)SharePoint Client Object Model (CSOM)
SharePoint Client Object Model (CSOM)
 
Introduction to the SharePoint Client Object Model and REST API
Introduction to the SharePoint Client Object Model and REST APIIntroduction to the SharePoint Client Object Model and REST API
Introduction to the SharePoint Client Object Model and REST API
 
Share point review qustions
Share point review qustionsShare point review qustions
Share point review qustions
 
SharePoint 2010 Client Object Model
SharePoint 2010 Client Object ModelSharePoint 2010 Client Object Model
SharePoint 2010 Client Object Model
 
Power Automate Techniques that "Saved Our Bacon"
Power Automate Techniques that "Saved Our Bacon"Power Automate Techniques that "Saved Our Bacon"
Power Automate Techniques that "Saved Our Bacon"
 
Integrating SharePoint 2010 and Visual Studio Lightswitch
Integrating SharePoint 2010 and Visual Studio LightswitchIntegrating SharePoint 2010 and Visual Studio Lightswitch
Integrating SharePoint 2010 and Visual Studio Lightswitch
 
Standards of rest api
Standards of rest apiStandards of rest api
Standards of rest api
 
Hypermedia APIs
Hypermedia APIsHypermedia APIs
Hypermedia APIs
 
SharePoint 2010 Enterprise Search
SharePoint 2010 Enterprise SearchSharePoint 2010 Enterprise Search
SharePoint 2010 Enterprise Search
 
Drupal and Apache Solr Search Go Together Like Pizza and Beer for Your Site
Drupal and Apache Solr Search Go Together Like Pizza and Beer for Your SiteDrupal and Apache Solr Search Go Together Like Pizza and Beer for Your Site
Drupal and Apache Solr Search Go Together Like Pizza and Beer for Your Site
 
Introduction To REST
Introduction To RESTIntroduction To REST
Introduction To REST
 
Building Beautiful REST APIs in ASP.NET Core
Building Beautiful REST APIs in ASP.NET CoreBuilding Beautiful REST APIs in ASP.NET Core
Building Beautiful REST APIs in ASP.NET Core
 
Programming web application
Programming web applicationProgramming web application
Programming web application
 
Charla desarrollo de apps con sharepoint y office 365
Charla   desarrollo de apps con sharepoint y office 365Charla   desarrollo de apps con sharepoint y office 365
Charla desarrollo de apps con sharepoint y office 365
 

Similar to Working With Sharepoint 2013 Apps Development

jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013
jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013
jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013Kiril Iliev
 
Webadi -a_sample_implementation
Webadi  -a_sample_implementationWebadi  -a_sample_implementation
Webadi -a_sample_implementation
Ashish Harbhajanka
 
Apache Aries Blog Sample
Apache Aries Blog SampleApache Aries Blog Sample
Apache Aries Blog Sample
Skills Matter
 
Power Shell and Sharepoint 2013
Power Shell and Sharepoint 2013Power Shell and Sharepoint 2013
Power Shell and Sharepoint 2013
Mohan Arumugam
 
Share Point Object Model
Share Point Object ModelShare Point Object Model
Share Point Object Model
SharePoint Experts
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
Joaquim Rocha
 
Angular js
Angular jsAngular js
Angular js
prasaddammalapati
 
Creating Professional Applications with the LinkedIn API
Creating Professional Applications with the LinkedIn APICreating Professional Applications with the LinkedIn API
Creating Professional Applications with the LinkedIn API
Kirsten Hunter
 
MuleSoft London Community February 2020 - MuleSoft and OData
MuleSoft London Community February 2020 - MuleSoft and ODataMuleSoft London Community February 2020 - MuleSoft and OData
MuleSoft London Community February 2020 - MuleSoft and OData
Pace Integration
 
An IT Pro Guide to Deploying and Managing SharePoint 2013 Apps
An IT Pro Guide to Deploying and Managing SharePoint 2013 AppsAn IT Pro Guide to Deploying and Managing SharePoint 2013 Apps
An IT Pro Guide to Deploying and Managing SharePoint 2013 Apps
Randy Williams
 
Automotive industry ppt
Automotive industry pptAutomotive industry ppt
Automotive industry ppt
sudharsanpremkumar1
 
How to build integrated, professional enterprise-grade cross-platform mobile ...
How to build integrated, professional enterprise-grade cross-platform mobile ...How to build integrated, professional enterprise-grade cross-platform mobile ...
How to build integrated, professional enterprise-grade cross-platform mobile ...
Appear
 
Http and REST APIs.
Http and REST APIs.Http and REST APIs.
Http and REST APIs.
Rahul Tanwani
 
RESTful API 제대로 만들기
RESTful API 제대로 만들기RESTful API 제대로 만들기
RESTful API 제대로 만들기
Juwon Kim
 
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
Evan Mullins
 
Getting into ember.js
Getting into ember.jsGetting into ember.js
Getting into ember.js
reybango
 
Share point hosted add ins munich
Share point hosted add ins munichShare point hosted add ins munich
Share point hosted add ins munich
Sonja Madsen
 
Search APIs & Universal Links
Search APIs & Universal LinksSearch APIs & Universal Links
Search APIs & Universal Links
Yusuke Kita
 
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With DeadlinesJBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
Tikal Knowledge
 

Similar to Working With Sharepoint 2013 Apps Development (20)

jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013
jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013
jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013
 
Webadi -a_sample_implementation
Webadi  -a_sample_implementationWebadi  -a_sample_implementation
Webadi -a_sample_implementation
 
Apache Aries Blog Sample
Apache Aries Blog SampleApache Aries Blog Sample
Apache Aries Blog Sample
 
Power Shell and Sharepoint 2013
Power Shell and Sharepoint 2013Power Shell and Sharepoint 2013
Power Shell and Sharepoint 2013
 
Share Point Object Model
Share Point Object ModelShare Point Object Model
Share Point Object Model
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
Angular js
Angular jsAngular js
Angular js
 
Creating Professional Applications with the LinkedIn API
Creating Professional Applications with the LinkedIn APICreating Professional Applications with the LinkedIn API
Creating Professional Applications with the LinkedIn API
 
MuleSoft London Community February 2020 - MuleSoft and OData
MuleSoft London Community February 2020 - MuleSoft and ODataMuleSoft London Community February 2020 - MuleSoft and OData
MuleSoft London Community February 2020 - MuleSoft and OData
 
An IT Pro Guide to Deploying and Managing SharePoint 2013 Apps
An IT Pro Guide to Deploying and Managing SharePoint 2013 AppsAn IT Pro Guide to Deploying and Managing SharePoint 2013 Apps
An IT Pro Guide to Deploying and Managing SharePoint 2013 Apps
 
Automotive industry ppt
Automotive industry pptAutomotive industry ppt
Automotive industry ppt
 
How to build integrated, professional enterprise-grade cross-platform mobile ...
How to build integrated, professional enterprise-grade cross-platform mobile ...How to build integrated, professional enterprise-grade cross-platform mobile ...
How to build integrated, professional enterprise-grade cross-platform mobile ...
 
Http and REST APIs.
Http and REST APIs.Http and REST APIs.
Http and REST APIs.
 
RESTful API 제대로 만들기
RESTful API 제대로 만들기RESTful API 제대로 만들기
RESTful API 제대로 만들기
 
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
 
Getting into ember.js
Getting into ember.jsGetting into ember.js
Getting into ember.js
 
Share point hosted add ins munich
Share point hosted add ins munichShare point hosted add ins munich
Share point hosted add ins munich
 
Search APIs & Universal Links
Search APIs & Universal LinksSearch APIs & Universal Links
Search APIs & Universal Links
 
Technologies for Websites
Technologies for WebsitesTechnologies for Websites
Technologies for Websites
 
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With DeadlinesJBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
 

Recently uploaded

Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 

Recently uploaded (20)

Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 

Working With Sharepoint 2013 Apps Development

  • 1. SharePoint Development, Training & Consulting By Pankaj Srivastava Skills: SharePoint 2013, Apps Development, .Net, C#, JQuery, JSON, Javascript Working With SharePoint 2013 App Model Using REST API-JQuery, JSON, AJAX Author: - Pankaj Kumar Srivastava Contact:-pankajshrivastav6@gmail.com Blog: - http://pshrivastavadotnet.blogspot.in/ Before we dive deep into SharePoint App Model first we have to understand the basic concept behind App Model. Why Microsoft born a new baby and named it “App Model”?? Don’t be panic I am sure once you read my whitepaper you guys will feel comfort to create a SharePoint Hosted App. So let’s begins the journey with me:- Why Apps?? App for SharePoint is a stand-alone, self-contained piece of functionality that extends the features and capabilities of a SharePoint site. Apps are targeted, lightweight, and easy-to-use, and do a great job at solving a user need. Apps will be executed outside the SharePoint Server, and in the Client machine or in the Cloud. This makes Apps makes easier installation& cleanup. In short it is just like ready to use plug-in in SharePoint. Types of Apps in SharePoint 2013:- 1. SharePoint Hosted: SharePoint-hosted apps contain only declarative content, such as HTML and JavaScript, and don’t have any server-side code that is packaged with them. SharePoint-hosted apps interact with SharePoint via the JavaScript object model or Representational State Transfer (REST) end-points and are client-side based. The design and interaction of these types of apps are similar to client-side design patterns used with sandboxed solutions. 2. Provider Hosted: A Provider-hosted app is one that has server-side components. These components are usually contained within an ASP.NET application and you have to provide a separate environment to host them. These server-side pieces can be developed in any technology as long as you can leverage OAuth and make REST calls. 3. Auto-Hosted: This new type of app only relates to Office 365 and SharePoint Online. It has server-side components similar to Provider-Hosted Apps. What makes it unique is that it not only provisions the app in SharePoint, but also automatically provisions components into Azure.
  • 2. Where my apps deployed? Two Birds come into picture if you talk about deployment  App Web: - The special website to which the app is deployed is called an app web, the app for SharePoint components and content, such as lists, content types, workflows, and pages, are deployed to a different website in a special isolated domain.  Host Web:-The website to which the app is installed is called the host web http://app-bdf2016ea7dacb.abcapps.com/sites/TestPankaj/EmployeeManagment https:// App_Prefix App_ID . App_Base_Domain / Domain_Relative_URL_of_Host_Web / App_Na me Lets Understand How REST actually work and What is ODATA? ODATA:-The Open Data Protocol (OData) is a Web protocol for querying and updating data How to create or consume the Open Data Protocol? OData defines a standard syntax which defines how resource representations (entities) are queried via a Restful URI: ex {http://site url/_api/web/lists} ODATA Restful Service:- SharePoint 2013 Rest API service Access Point basic understanding:- Site :-http: //server/site/_api/site Web:-http: //server/site/_api/web User Profile:-http: // server/site/_api/SP.UserProfiles.PeopleManager Search:-http: // server/site/_api/search Publishing: - http:// server/site/_api/publishing So if once you are familiar with REST API SharePoint 2013 you would like to do more with REST so let’s dive deep.
  • 3. ODATA - SharePoint 2013 REST API Query Operators $select - Specifies which fields are included in the returned data. EX:-http://abc-sharepoint.com/Test/ _api/web/lists/getByTitle ('Employee')/items? $select=Title, EmpID $filter - Specifies which members of a collection, such as the items in a list, are returned. Ex.:-http://abc-sharepoint.com/Test /_api/web/lists/getByTitle('Employee')/items?$filter=EMPID eq '123‘ $expand: - Specifies which projected fields from a joined list are returned. $top- Returns only the first n items of a collection or list. http://abc-sharepoint.com/Test _api/web/lists/getByTitle( Employee)/items?$select=Title&$filter=Title eq ‘Pankaj'&$top=2 $skip: - Skips the first n items of a collection or list and returns the rest. _api/web/lists/getbytitle('Employee')/items?$skip=100&$top=100 $orderby: - Specifies the field that’s used to sort the data before it’s returned http://abc-sharepoint.com/Test _api/web/lists/getByTitle( Employee)/items? orderby =EMPID Logical Query with ODATA SharePoint 2013 REST API:- ODATA SharePoint 2013 REST API String Functions :-
  • 4. ODATA SharePoint 2013 REST API Date/Math/Type Functions:- CRUD - Creating, Reading, Updating and Deleting Entries SharePoint 2013 Using REST API Let’s understand some basic method which is used while CRUD Operation: GET: Get a collection of entries (read) POST: Create a new entry from an entry document (insert). MERGE: Update an existing entry with an entry document. DELETE: Remove an entry. So I have one list in my App I named it Employee and it will be located at AppWeb after deployment as I discuss above. Important:-  The _spPageContextInfo JavaScript object has been around since SharePoint 2007. It provides really easy way to start building the correct _api URI,  The point of note here is that the odata=verbose appended to the end is required in order for the service call to succeed.
  • 5. Examples GET Method:- Get List Items Form SharePoint List Using REST API with Ajax. $.ajax( { url: _spPageContextInfo.webServerRelativeUrl + "/_api/web/lists/getByTitle('Employee')/items/", type: "GET", headers: { "accept": "application/json;odata=verbose", }, success: function (data) { // so once Service called Successfully it will return data in json format. If(data.d.results.length>0) { //Foreach loop $.each(data.d.results, function (i, item) { “<table><tr><td>”+ data.d.results[i].Title +”</td></tr></table>” }); } }, error: function (err) { console.log(JSON.stringify(err)); } }); Example POST Method:- Add an Item in SharePoint List Using POST Method. var postitem = { "__metadata": { "type": SP.Data.EmployeeListItem }, "Title": “Pankaj”, "EMPID”:”51446959”, "Comments": “Test Commnets”, }; $.ajax({ url: _spPageContextInfo.webServerRelativeUrl + "/_api/web/lists/getByTitle('Employee')/items", type: "POST", contentType: "application/json;odata=verbose", data: postitem, headers: { "accept": "application/json;odata=verbose", "X-RequestDigest": $("#__REQUESTDIGEST").val() }, success: function () { alert(“An Item Added SuccessFully”); }, error: function (err) { console.log(JSON.stringify(err)); } });  The important thing to understand is that you must send the form digest along with any POST request or nothing will get updated  form digest is stored as the value of a well known element on the page: the element with id ‘__REQUESTDIGEST’  It must be passed as the value of the X-RequestDigest header, It must be passed as the value of the X- RequestDigest header.
  • 6.  __metadata 'type' property with the list item entity type of the list. Examples DELETE Method:- Delete an item from list Using DELETE Method. $.ajax( { url: _spPageContextInfo.webServerRelativeUrl + "/_api/web/lists/getByTitle('Employee')/items('1234')", type: "DELETE", headers: { "accept": "application/json;odata=verbose", "X-RequestDigest": $("#__REQUESTDIGEST").val(), "IF-MATCH": "*" }, success: function (data) { alert(‘Item Deleted successfully’); }, error: function (err) { console.log(JSON.stringify(err)); } } ); Examples MERGE Method:- Update an existing item from list Using MERGE Method. var Updateitem = { "__metadata": { "type": SP.Data.EmployeeListItem }, "Title": “Pankaj Kumar Srivastav”, "EMPID”:”51446959”, "Comments": “ My Updated Test Commnets”, }; $.ajax( { url: _spPageContextInfo.webServerRelativeUrl + "/_api/web/lists/getByTitle('Employee')/items('1234')", type: "POST", contentType: "application/json;odata=verbose", data: Updateitem, headers: { "accept": "application/json;odata=verbose", "X-RequestDigest": $("#__REQUESTDIGEST").val(), "X-HTTP-Method": "MERGE", "IF-MATCH": "*" }, success: function () { alert(‘Item Upodated Successfully’); }, error: function (err) { console.log(JSON.stringify(err)); } } I Hope this will help you a lot to develop a New SharepointHostedApp Using REST API in SharePoint 2013/Office 365.
  • 7. You have to be good knowledge in Javascript, Jquery, and JSON before Start Development on SharePoint Hosted App Model or AppPart. If you have any Doubt let me drop a mail: - pankajshrivastav6@gmail.com (Pankaj Kumar Srivastava)