SlideShare uma empresa Scribd logo
1 de 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)

Mais conteúdo relacionado

Mais procurados

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 APIChris 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 DevelopmentRob 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 APIRob Windsor
 
Share point review qustions
Share point review qustionsShare point review qustions
Share point review qustionsthan sare
 
SharePoint 2010 Client Object Model
SharePoint 2010 Client Object ModelSharePoint 2010 Client Object Model
SharePoint 2010 Client Object ModelG. 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
 
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 Sitenyccamp
 
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 CoreStormpath
 
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 365Luis Valencia
 

Mais procurados (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
 

Semelhante a 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_implementationAshish Harbhajanka
 
Apache Aries Blog Sample
Apache Aries Blog SampleApache Aries Blog Sample
Apache Aries Blog SampleSkills Matter
 
Power Shell and Sharepoint 2013
Power Shell and Sharepoint 2013Power Shell and Sharepoint 2013
Power Shell and Sharepoint 2013Mohan Arumugam
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to DjangoJoaquim Rocha
 
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 APIKirsten 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 ODataPace 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 AppsRandy Williams
 
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
 
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.jsreybango
 
Share point hosted add ins munich
Share point hosted add ins munichShare point hosted add ins munich
Share point hosted add ins munichSonja Madsen
 
Search APIs & Universal Links
Search APIs & Universal LinksSearch APIs & Universal Links
Search APIs & Universal LinksYusuke 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 DeadlinesTikal Knowledge
 

Semelhante a 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
 

Último

How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17Celine George
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17Celine George
 
M-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptxM-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptxDr. Santhosh Kumar. N
 
Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.EnglishCEIPdeSigeiro
 
The Singapore Teaching Practice document
The Singapore Teaching Practice documentThe Singapore Teaching Practice document
The Singapore Teaching Practice documentXsasf Sfdfasd
 
General views of Histopathology and step
General views of Histopathology and stepGeneral views of Histopathology and step
General views of Histopathology and stepobaje godwin sunday
 
HED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfHED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfMohonDas
 
CapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapitolTechU
 
The Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George WellsThe Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George WellsEugene Lysak
 
How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17Celine George
 
How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17Celine George
 
3.21.24 The Origins of Black Power.pptx
3.21.24  The Origins of Black Power.pptx3.21.24  The Origins of Black Power.pptx
3.21.24 The Origins of Black Power.pptxmary850239
 
Diploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfDiploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfMohonDas
 
How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17Celine George
 
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptxClinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptxraviapr7
 
CAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxCAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxSaurabhParmar42
 
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptxSandy Millin
 
Philosophy of Education and Educational Philosophy
Philosophy of Education  and Educational PhilosophyPhilosophy of Education  and Educational Philosophy
Philosophy of Education and Educational PhilosophyShuvankar Madhu
 
In - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxIn - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxAditiChauhan701637
 
Presentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a ParagraphPresentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a ParagraphNetziValdelomar1
 

Último (20)

How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17
 
M-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptxM-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptx
 
Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.
 
The Singapore Teaching Practice document
The Singapore Teaching Practice documentThe Singapore Teaching Practice document
The Singapore Teaching Practice document
 
General views of Histopathology and step
General views of Histopathology and stepGeneral views of Histopathology and step
General views of Histopathology and step
 
HED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfHED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdf
 
CapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptx
 
The Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George WellsThe Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George Wells
 
How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17
 
How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17
 
3.21.24 The Origins of Black Power.pptx
3.21.24  The Origins of Black Power.pptx3.21.24  The Origins of Black Power.pptx
3.21.24 The Origins of Black Power.pptx
 
Diploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfDiploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdf
 
How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17
 
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptxClinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
 
CAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxCAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptx
 
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
 
Philosophy of Education and Educational Philosophy
Philosophy of Education  and Educational PhilosophyPhilosophy of Education  and Educational Philosophy
Philosophy of Education and Educational Philosophy
 
In - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxIn - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptx
 
Presentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a ParagraphPresentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a Paragraph
 

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)