SlideShare ist ein Scribd-Unternehmen logo
1 von 7
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)

Weitere ähnliche Inhalte

Was ist angesagt?

SharePoint 2010 Application Development Overview
SharePoint 2010 Application Development OverviewSharePoint 2010 Application Development Overview
SharePoint 2010 Application Development Overview
Rob Windsor
 
SharePoint 2010 Client-side Object Model
SharePoint 2010 Client-side Object ModelSharePoint 2010 Client-side Object Model
SharePoint 2010 Client-side Object Model
Phil Wicklund
 
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
 
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
Rob Windsor
 
SharePoint 2010 Enterprise Search
SharePoint 2010 Enterprise SearchSharePoint 2010 Enterprise Search
SharePoint 2010 Enterprise Search
Agnes Molnar
 
Programming web application
Programming web applicationProgramming web application
Programming web application
aspnet123
 

Was ist angesagt? (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
 

Ähnlich wie 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 2013
Kiril Iliev
 

Ähnlich wie 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
 

Kürzlich hochgeladen

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 

Kürzlich hochgeladen (20)

Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 

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)