SlideShare une entreprise Scribd logo
1  sur  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)

Contenu connexe

Tendances

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
 

Tendances (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
 

Similaire à 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
 

Similaire à 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
 

Dernier

Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 

Dernier (20)

Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 

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)