SlideShare ist ein Scribd-Unternehmen logo
1 von 6
Downloaden Sie, um offline zu lesen
SP REST API Documentation
Table of Contents
User Authentication:..............................................................................................................................2
For an Advanced Concept please refer here:....................................................................................2
Simple REST API URL 3 Main Blocks: .....................................................................................................2
Simple REST API URL to Create a Folder:...........................................................................................2
Simple REST API URL to Get a Folder:................................................................................................2
Simple REST API URL to Update a Folder: .........................................................................................2
Simple REST API URL to Remove a Folder:........................................................................................3
Simple REST API URL to Create a File with Content:.........................................................................3
Simple REST API URL to Get a File with Content:..............................................................................3
For getting file based on the name................................................................................................3
For Reading a file content with a given name...............................................................................3
Simple REST API URL to Update the File with Content:....................................................................3
Simple REST API URL to Delete the File:............................................................................................3
Advance REST API Concepts Implementation Section wise: ................................................................4
How to Upload a document in a library: ...........................................................................................4
How to bind attachments from a library:..........................................................................................4
How to Delete a document from a library: .......................................................................................5
How to Create folder/ subfolders in a library:..................................................................................6
Some error request codes from REST API: ............................................................................................6
Quick Reference on SP REST API + PowerShell: ....................................................................................6
Author: Kaveri Veera Bharat Bhushan
Target Audience: Anyone who knows SharePoint, REST API, PowerShell concepts etc.
SP REST API Documentation
User Authentication:
It Is handled by the portal.office.com automatically at the time of User Signing which gets
reflected across all the Sites/Libraries/Folders/SubFolders/Files etc as it promotes Service
Account Authenticate via SharePointOnlineCredentials.
Can be further more customized using Item Pane[In Modern SharePoint] & Share Option for
establishing Item Level/Folder Level permissions to promote only the required members
sharing.
For an Advanced Concept please refer here:
Access SharePoint
Online REST API Via Postman With User Context.docx
Simple REST API URL 3 Main Blocks:
➢ Get the URL ready
➢ Metadata info POST
➢ REST Type(GET,PUT,POST,MERGE,DELETE)
View the results finally after above REST API URL is properly framed.
Simple REST API URL to Create a Folder:
<SPSiteURL>/_api/web/<FolderName/LibName>
{‘_metadata’:{‘type’:’SP.Folder’},’
ServerRelativeUrl’:’/sites/dev/<LibName>/<FolderName>’}
REQUEST TYPE: POST
Note: Use Folder name if for creating a Sub-Folder & Lib Name for creating a Folder.
Simple REST API URL to Get a Folder:
<SPSiteURL>/_api/web/GetFolderByServerRelativeUrl(‘/sites/dev/<LibName>/<FolderNam
e>’)
$select=Title
/_api/web/GetFolderByServerRelativeUrl(‘/sites/dev/<LibName>’)/folders?select=
ServerRelativeUrl
REQUEST TYPE: GET
Simple REST API URL to Update a Folder:
<SPSiteURL>/_api/web/GetFolderByServerRelativeURL(‘/sites/dev/<LibName>/<OldFolder
Name>’)/ListItemAllFields?$select= FileLeafRef
{‘_metadata’:{‘type’:
SP REST API Documentation
SP.Data.<LibraryInternalName>Item}.’FileLeafRef’:’<NewFolderName>’
}
REQUEST TYPE: PUT
Simple REST API URL to Remove a Folder:
<SPSiteURL>/_api/web/GetFolderByServerRelativeURL(‘/sites/dev/<LibName>/OldFolderN
ame’)/recycle
REQUEST TYPE: DELETE
Simple REST API URL to Create a File with Content:
<SPSiteURL>/_api/web/GetFolderByServerRelativeURL(‘/sites/dev/<LibName>’)/Files/add(u
rl=’<FileName.txt>’,overwrite=true)
“Add Some Text!!”
REQUEST TYPE: POST
Note: Above Extension could be any type of document like .txt, .doc, .ppt etc.
Simple REST API URL to Get a File with Content:
For getting all the Files
<SPSiteURL>/_api/web/GetFolderByServerRelativeURL(‘/sites/dev/<LibraryName>’)/Files
For getting file based on the name
<SPSiteURL>/_api/web/GetFolderByServerRelativeURL(‘/sites/dev/<LibraryName>’)/Files(‘d
emo.txt’)
For Reading a file content with a given name
<SPSiteURL>/_api/web/GetFolderByServerRelativeURL(‘/sites/dev/<LibraryName>’)/Files(‘d
emo.txt’)/$value
REQUEST TYPE: GET
Simple REST API URL to Update the File with Content:
<SPSiteURL>/_api/web/GetFolderByServerRelativeURL(‘/sites/dev/<LibraryName>’)/Files(‘d
emo.txt’)/$value
“Add New Content to be updated!”
REQUEST TYPE: PUT
Simple REST API URL to Delete the File:
<SPSiteURL>/_api/web/GetFolderByServerRelativeURL(‘/sites/dev/<LibraryName>’)/Files(‘d
emo.txt’)/recycle
REQUEST TYPE: DELETE
SP REST API Documentation
Advance REST API Concepts Implementation Section wise:
How to Upload a document in a library:
/*********Function to upload files ********/
/** Here I am uploading multiple files by using the attachment Buffer: array which is having
multiple file info.
If you want to upload single file we can skip the iteration of array on below code. **/
function uploadFile() {
$.each(attachmentBuffer, function () {
var url = String.format(
“{0}/_api/Web/Lists/getByTitle(‘” + attachmentLibraryName + “‘)/RootFolder/folders(‘” +
folderName + “‘)/Files/Add(url='{1}’, overwrite=true)”,
appWebUrl.split(‘appname’)[0], this.File.name);
/* attachmentLibraryName , folderName is the library name which is from constant
entry. this.File.name dynamic name we can directly pass file.name */
$.ajax({
url: url,
method: “POST”,
contentType: “application/json;odata=verbose”,
processData: false,
data: this.File,
async: false,
headers: {
“Accept”: “application/json; odata=verbose”,
“X-RequestDigest”: formDigestValues
},
success: function () {
onUploadSucess();
},
error: function () {
onUploadFailure();
}
});
});
}
How to bind attachments from a library:
/*********Function to bind the attachments from document library ********/
function getAttachments() {
var getDocumentsUrl = String.format(
“{0}/_api/web/GetFolderByServerRelativeUrl(‘” + attachmentLibraryUrl + “” + “/” +
SP REST API Documentation
folderName + “‘)/files?$select=Name,ServerRelativeUrl”,
appWebUrl.split(‘appname’)[0]);
$.ajax({
url: getDocumentsUrl,
type: ‘GET’,
headers: {
“Accept”: “application/json; odata=verbose”,
“content-type”: “application/json;odata=verbose”
},
success: function (data) {
$.each(data.d.results, function (i, result) {
/* The below code which will disply the files from the folder */
$(“[id^=’fileAttachments’]”).append(‘<a href=”‘ + result.ServerRelativeUrl + ‘”
target=”_blank”>’ + result.Name + ‘</a><br/>’);
});
},
error: function onGetFilesFailure(response) {
console.log(response.status + ‘ ‘ + response.statusText);
}
});
}
How to Delete a document from a library:
/*********Function to delete a document ********/
$.ajax(
{
"url":
"/sites/test/_api/web/getfilebyserverrelativeurl('/sites/test/Shared%20Documents/Airplane
Logo.jpg')",
"method": "POST",
"headers": {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-HTTP-Method": "DELETE",
"If-Match": "*",
"X-RequestDigest": "yourRequestDigestGoesHere"
},
"success" = successfunction,
"error" = errorfunction
}
);
SP REST API Documentation
How to Create folder/ subfolders in a library:
/*********Function to create the folder ********/
function createFolder() {
var docCreationUrl = appWebUrl.split(‘appname’)[0];
/* Here i am doing manipulation at host web level, as per the my requirement i am using the
above url instead of _spPageContextInfo.siteAbsoluteUrl */
var serverRelativeUrl = docCreationUrl.slice(docCreationUrl.indexOf(‘/’) + 2);
serverRelativeUrl = serverRelativeUrl.slice(serverRelativeUrl.indexOf(‘/’) + 0);
var docLibURL = { ‘__metadata’: { ‘type’: ‘SP.Folder’ }, ‘ServerRelativeUrl’: serverRelativeUrl
+ “/” + ‘attachmentLibraryUrl’ + “/” + ‘folderName’ };
/* attachmentLibraryUrl is the library url */
return $.ajax({
url: appWebUrl.split(‘appname’)[0] + “/_api/web/folders”,
type: “POST”,
contentType: “application/json;odata=verbose”,
data: JSON.stringify(docLibURL),
headers: {
“Accept”: “application/json;odata=verbose”,
“X-RequestDigest”: formDigestValues
/* formDigestValues is the request digest value like $(“#__REQUESTDIGEST”).val() **/
}, success: function () {
onAttachmentSucess();
},
error: function () {
onAttachmentFailure();
}
});
}
Some error request codes from REST API:
Http 404 – You queried an invalid URL
Http 400 – Bad request, the URL was right but you sent an invalid rest call
Http 412 – Concurrency violation
Http 500 – Genuine server side error, error will include correlation ID
Quick Reference on SP REST API + PowerShell:
https://collab365.community/tutorial-create-read-update-delete-files-sharepoint-using-
rest/

Weitere ähnliche Inhalte

Was ist angesagt?

Couchbase & FTS
Couchbase & FTSCouchbase & FTS
Couchbase & FTSRich Lee
 
Rails 3 Beautiful Code
Rails 3 Beautiful CodeRails 3 Beautiful Code
Rails 3 Beautiful CodeGreggPollack
 
So You're the New SharePoint Administrator
So You're the New SharePoint AdministratorSo You're the New SharePoint Administrator
So You're the New SharePoint AdministratorDan Usher
 
Javascript Application Architecture with Backbone.JS
Javascript Application Architecture with Backbone.JSJavascript Application Architecture with Backbone.JS
Javascript Application Architecture with Backbone.JSMin Ming Lo
 
浜松Rails3道場 其の参 Controller編
浜松Rails3道場 其の参 Controller編浜松Rails3道場 其の参 Controller編
浜松Rails3道場 其の参 Controller編Masakuni Kato
 
Introduction to ElasticSearch
Introduction to ElasticSearchIntroduction to ElasticSearch
Introduction to ElasticSearchSimobo
 
[SharePoint Korea Conference 2013 / 강율구] Sharepoint 스마트하게 개발하기
[SharePoint Korea Conference 2013 / 강율구] Sharepoint 스마트하게 개발하기[SharePoint Korea Conference 2013 / 강율구] Sharepoint 스마트하게 개발하기
[SharePoint Korea Conference 2013 / 강율구] Sharepoint 스마트하게 개발하기lanslote
 
Designing CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsDesigning CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsNeil Crookes
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Elena Kolevska
 
Laravel 로 배우는 서버사이드 #5
Laravel 로 배우는 서버사이드 #5Laravel 로 배우는 서버사이드 #5
Laravel 로 배우는 서버사이드 #5성일 한
 
Service approach for development REST API in Symfony2
Service approach for development REST API in Symfony2Service approach for development REST API in Symfony2
Service approach for development REST API in Symfony2Sumy PHP User Grpoup
 
Try using Aeromock by Marverick, Inc.
Try using Aeromock by Marverick, Inc.Try using Aeromock by Marverick, Inc.
Try using Aeromock by Marverick, Inc.scalaconfjp
 
Create a res tful services api in php.
Create a res tful services api in php.Create a res tful services api in php.
Create a res tful services api in php.Adeoye Akintola
 
Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2Sumy PHP User Grpoup
 
AngularJS with Slim PHP Micro Framework
AngularJS with Slim PHP Micro FrameworkAngularJS with Slim PHP Micro Framework
AngularJS with Slim PHP Micro FrameworkBackand Cohen
 

Was ist angesagt? (20)

Codegnitorppt
CodegnitorpptCodegnitorppt
Codegnitorppt
 
Couchbase & FTS
Couchbase & FTSCouchbase & FTS
Couchbase & FTS
 
Rails 3 Beautiful Code
Rails 3 Beautiful CodeRails 3 Beautiful Code
Rails 3 Beautiful Code
 
So You're the New SharePoint Administrator
So You're the New SharePoint AdministratorSo You're the New SharePoint Administrator
So You're the New SharePoint Administrator
 
Javascript Application Architecture with Backbone.JS
Javascript Application Architecture with Backbone.JSJavascript Application Architecture with Backbone.JS
Javascript Application Architecture with Backbone.JS
 
浜松Rails3道場 其の参 Controller編
浜松Rails3道場 其の参 Controller編浜松Rails3道場 其の参 Controller編
浜松Rails3道場 其の参 Controller編
 
Introduction to ElasticSearch
Introduction to ElasticSearchIntroduction to ElasticSearch
Introduction to ElasticSearch
 
[SharePoint Korea Conference 2013 / 강율구] Sharepoint 스마트하게 개발하기
[SharePoint Korea Conference 2013 / 강율구] Sharepoint 스마트하게 개발하기[SharePoint Korea Conference 2013 / 강율구] Sharepoint 스마트하게 개발하기
[SharePoint Korea Conference 2013 / 강율구] Sharepoint 스마트하게 개발하기
 
Getting Started-with-Laravel
Getting Started-with-LaravelGetting Started-with-Laravel
Getting Started-with-Laravel
 
Designing CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsDesigning CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIs
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5
 
Laravel 로 배우는 서버사이드 #5
Laravel 로 배우는 서버사이드 #5Laravel 로 배우는 서버사이드 #5
Laravel 로 배우는 서버사이드 #5
 
Django
DjangoDjango
Django
 
Laravel intake 37 all days
Laravel intake 37 all daysLaravel intake 37 all days
Laravel intake 37 all days
 
Service approach for development REST API in Symfony2
Service approach for development REST API in Symfony2Service approach for development REST API in Symfony2
Service approach for development REST API in Symfony2
 
Try using Aeromock by Marverick, Inc.
Try using Aeromock by Marverick, Inc.Try using Aeromock by Marverick, Inc.
Try using Aeromock by Marverick, Inc.
 
Phinx talk
Phinx talkPhinx talk
Phinx talk
 
Create a res tful services api in php.
Create a res tful services api in php.Create a res tful services api in php.
Create a res tful services api in php.
 
Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2
 
AngularJS with Slim PHP Micro Framework
AngularJS with Slim PHP Micro FrameworkAngularJS with Slim PHP Micro Framework
AngularJS with Slim PHP Micro Framework
 

Ähnlich wie SP Rest API Documentation

SCR Annotations for Fun and Profit
SCR Annotations for Fun and ProfitSCR Annotations for Fun and Profit
SCR Annotations for Fun and ProfitMike Pfaff
 
Forge: Under the Hood
Forge: Under the HoodForge: Under the Hood
Forge: Under the HoodAtlassian
 
Using WordPress as your application stack
Using WordPress as your application stackUsing WordPress as your application stack
Using WordPress as your application stackPaul Bearne
 
Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013
Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013
Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013Amazon Web Services
 
Intro to fog and openstack jp
Intro to fog and openstack jpIntro to fog and openstack jp
Intro to fog and openstack jpSatoshi Konno
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformAntonio Peric-Mazar
 
Google Cloud Endpoints - Soft Uni 19.06.2014
Google Cloud Endpoints - Soft Uni 19.06.2014Google Cloud Endpoints - Soft Uni 19.06.2014
Google Cloud Endpoints - Soft Uni 19.06.2014Dimitar Danailov
 
REST API Best Practices & Implementing in Codeigniter
REST API Best Practices & Implementing in CodeigniterREST API Best Practices & Implementing in Codeigniter
REST API Best Practices & Implementing in CodeigniterSachin G Kulkarni
 
Are you getting Sleepy. REST in SharePoint Apps
Are you getting Sleepy. REST in SharePoint AppsAre you getting Sleepy. REST in SharePoint Apps
Are you getting Sleepy. REST in SharePoint AppsLiam Cleary [MVP]
 
Boost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco GralikeBoost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco GralikeMarco Gralike
 
API Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsAPI Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsTom Johnson
 
O365 DEVCamp Los Angeles June 16, 2015 Module 06 Hook into SharePoint APIs wi...
O365 DEVCamp Los Angeles June 16, 2015 Module 06 Hook into SharePoint APIs wi...O365 DEVCamp Los Angeles June 16, 2015 Module 06 Hook into SharePoint APIs wi...
O365 DEVCamp Los Angeles June 16, 2015 Module 06 Hook into SharePoint APIs wi...Ivan Sanders
 
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話Takehito Tanabe
 
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
 
SpringBootCompleteBootcamp.pptx
SpringBootCompleteBootcamp.pptxSpringBootCompleteBootcamp.pptx
SpringBootCompleteBootcamp.pptxSUFYAN SATTAR
 
Creating a modern web application using Symfony API Platform, ReactJS and Red...
Creating a modern web application using Symfony API Platform, ReactJS and Red...Creating a modern web application using Symfony API Platform, ReactJS and Red...
Creating a modern web application using Symfony API Platform, ReactJS and Red...Jesus Manuel Olivas
 
OAuth 2.0 and Library
OAuth 2.0 and LibraryOAuth 2.0 and Library
OAuth 2.0 and LibraryKenji Otsuka
 

Ähnlich wie SP Rest API Documentation (20)

SCR Annotations for Fun and Profit
SCR Annotations for Fun and ProfitSCR Annotations for Fun and Profit
SCR Annotations for Fun and Profit
 
Forge: Under the Hood
Forge: Under the HoodForge: Under the Hood
Forge: Under the Hood
 
Using WordPress as your application stack
Using WordPress as your application stackUsing WordPress as your application stack
Using WordPress as your application stack
 
ZH爱丽丝梦游仙境
ZH爱丽丝梦游仙境ZH爱丽丝梦游仙境
ZH爱丽丝梦游仙境
 
Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013
Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013
Zero to Sixty: AWS CloudFormation (DMG201) | AWS re:Invent 2013
 
Intro to fog and openstack jp
Intro to fog and openstack jpIntro to fog and openstack jp
Intro to fog and openstack jp
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API Platform
 
Google Cloud Endpoints - Soft Uni 19.06.2014
Google Cloud Endpoints - Soft Uni 19.06.2014Google Cloud Endpoints - Soft Uni 19.06.2014
Google Cloud Endpoints - Soft Uni 19.06.2014
 
REST API Best Practices & Implementing in Codeigniter
REST API Best Practices & Implementing in CodeigniterREST API Best Practices & Implementing in Codeigniter
REST API Best Practices & Implementing in Codeigniter
 
Are you getting Sleepy. REST in SharePoint Apps
Are you getting Sleepy. REST in SharePoint AppsAre you getting Sleepy. REST in SharePoint Apps
Are you getting Sleepy. REST in SharePoint Apps
 
Boost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco GralikeBoost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
 
Laravel 5
Laravel 5Laravel 5
Laravel 5
 
API Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsAPI Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIs
 
O365 DEVCamp Los Angeles June 16, 2015 Module 06 Hook into SharePoint APIs wi...
O365 DEVCamp Los Angeles June 16, 2015 Module 06 Hook into SharePoint APIs wi...O365 DEVCamp Los Angeles June 16, 2015 Module 06 Hook into SharePoint APIs wi...
O365 DEVCamp Los Angeles June 16, 2015 Module 06 Hook into SharePoint APIs wi...
 
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
 
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
 
SpringBootCompleteBootcamp.pptx
SpringBootCompleteBootcamp.pptxSpringBootCompleteBootcamp.pptx
SpringBootCompleteBootcamp.pptx
 
Rest hello world_tutorial
Rest hello world_tutorialRest hello world_tutorial
Rest hello world_tutorial
 
Creating a modern web application using Symfony API Platform, ReactJS and Red...
Creating a modern web application using Symfony API Platform, ReactJS and Red...Creating a modern web application using Symfony API Platform, ReactJS and Red...
Creating a modern web application using Symfony API Platform, ReactJS and Red...
 
OAuth 2.0 and Library
OAuth 2.0 and LibraryOAuth 2.0 and Library
OAuth 2.0 and Library
 

Mehr von IT Industry

DOOMS DAY SUPERHACKED SERIES PROJECTIONZ.pptx
DOOMS DAY SUPERHACKED SERIES PROJECTIONZ.pptxDOOMS DAY SUPERHACKED SERIES PROJECTIONZ.pptx
DOOMS DAY SUPERHACKED SERIES PROJECTIONZ.pptxIT Industry
 
ROULETTE SUPERHACKED PYTHONCODE SERIES.pptx
ROULETTE SUPERHACKED PYTHONCODE SERIES.pptxROULETTE SUPERHACKED PYTHONCODE SERIES.pptx
ROULETTE SUPERHACKED PYTHONCODE SERIES.pptxIT Industry
 
Why I AM Prime Optimus Architect Consultant of Advanced AI Insights with Micr...
Why I AM Prime Optimus Architect Consultant of Advanced AI Insights with Micr...Why I AM Prime Optimus Architect Consultant of Advanced AI Insights with Micr...
Why I AM Prime Optimus Architect Consultant of Advanced AI Insights with Micr...IT Industry
 
KV Bharat Bhushan_13 Yrs_AI Insights Microsoft365 Prime Optimus Architect Con...
KV Bharat Bhushan_13 Yrs_AI Insights Microsoft365 Prime Optimus Architect Con...KV Bharat Bhushan_13 Yrs_AI Insights Microsoft365 Prime Optimus Architect Con...
KV Bharat Bhushan_13 Yrs_AI Insights Microsoft365 Prime Optimus Architect Con...IT Industry
 
Mr. MULTIUNIVERSAL MJ SHARABHA KALKI LION KING’S ASTRO SPACE ZODIAC SLIDESHOW...
Mr. MULTIUNIVERSAL MJ SHARABHA KALKI LION KING’S ASTRO SPACE ZODIAC SLIDESHOW...Mr. MULTIUNIVERSAL MJ SHARABHA KALKI LION KING’S ASTRO SPACE ZODIAC SLIDESHOW...
Mr. MULTIUNIVERSAL MJ SHARABHA KALKI LION KING’S ASTRO SPACE ZODIAC SLIDESHOW...IT Industry
 
MY SCARJO123 SRUTHIVKV.pdf
MY SCARJO123 SRUTHIVKV.pdfMY SCARJO123 SRUTHIVKV.pdf
MY SCARJO123 SRUTHIVKV.pdfIT Industry
 
MR. MEGAONE KALKI LION KING ZODIAC VS STARS KA SULTAN GANDHI_15081988_3008208...
MR. MEGAONE KALKI LION KING ZODIAC VS STARS KA SULTAN GANDHI_15081988_3008208...MR. MEGAONE KALKI LION KING ZODIAC VS STARS KA SULTAN GANDHI_15081988_3008208...
MR. MEGAONE KALKI LION KING ZODIAC VS STARS KA SULTAN GANDHI_15081988_3008208...IT Industry
 
MR.MULTIVERSAL COLOR PhotoS Album SERIES - Once More Plz.pptx
MR.MULTIVERSAL COLOR PhotoS Album SERIES - Once More Plz.pptxMR.MULTIVERSAL COLOR PhotoS Album SERIES - Once More Plz.pptx
MR.MULTIVERSAL COLOR PhotoS Album SERIES - Once More Plz.pptxIT Industry
 
Document Library Folder Operations User Guide
Document Library Folder Operations User GuideDocument Library Folder Operations User Guide
Document Library Folder Operations User GuideIT Industry
 
Step by Step Personal Drive to One Drive Migration using SPMT
Step by Step Personal Drive to One Drive Migration using SPMTStep by Step Personal Drive to One Drive Migration using SPMT
Step by Step Personal Drive to One Drive Migration using SPMTIT Industry
 
PDrive Validation Status Documentation
PDrive Validation Status DocumentationPDrive Validation Status Documentation
PDrive Validation Status DocumentationIT Industry
 
Total ODFB Migration Process through SPMT Tool
Total ODFB Migration Process through SPMT ToolTotal ODFB Migration Process through SPMT Tool
Total ODFB Migration Process through SPMT ToolIT Industry
 
Mover Migration from Box to One drive
Mover Migration from Box to One driveMover Migration from Box to One drive
Mover Migration from Box to One driveIT Industry
 
Box vs OneDrive Features Comparison
Box vs OneDrive Features ComparisonBox vs OneDrive Features Comparison
Box vs OneDrive Features ComparisonIT Industry
 
Modern SharePoint Content Management Training
Modern SharePoint Content Management TrainingModern SharePoint Content Management Training
Modern SharePoint Content Management TrainingIT Industry
 
Box vs One Drive
Box vs One DriveBox vs One Drive
Box vs One DriveIT Industry
 

Mehr von IT Industry (16)

DOOMS DAY SUPERHACKED SERIES PROJECTIONZ.pptx
DOOMS DAY SUPERHACKED SERIES PROJECTIONZ.pptxDOOMS DAY SUPERHACKED SERIES PROJECTIONZ.pptx
DOOMS DAY SUPERHACKED SERIES PROJECTIONZ.pptx
 
ROULETTE SUPERHACKED PYTHONCODE SERIES.pptx
ROULETTE SUPERHACKED PYTHONCODE SERIES.pptxROULETTE SUPERHACKED PYTHONCODE SERIES.pptx
ROULETTE SUPERHACKED PYTHONCODE SERIES.pptx
 
Why I AM Prime Optimus Architect Consultant of Advanced AI Insights with Micr...
Why I AM Prime Optimus Architect Consultant of Advanced AI Insights with Micr...Why I AM Prime Optimus Architect Consultant of Advanced AI Insights with Micr...
Why I AM Prime Optimus Architect Consultant of Advanced AI Insights with Micr...
 
KV Bharat Bhushan_13 Yrs_AI Insights Microsoft365 Prime Optimus Architect Con...
KV Bharat Bhushan_13 Yrs_AI Insights Microsoft365 Prime Optimus Architect Con...KV Bharat Bhushan_13 Yrs_AI Insights Microsoft365 Prime Optimus Architect Con...
KV Bharat Bhushan_13 Yrs_AI Insights Microsoft365 Prime Optimus Architect Con...
 
Mr. MULTIUNIVERSAL MJ SHARABHA KALKI LION KING’S ASTRO SPACE ZODIAC SLIDESHOW...
Mr. MULTIUNIVERSAL MJ SHARABHA KALKI LION KING’S ASTRO SPACE ZODIAC SLIDESHOW...Mr. MULTIUNIVERSAL MJ SHARABHA KALKI LION KING’S ASTRO SPACE ZODIAC SLIDESHOW...
Mr. MULTIUNIVERSAL MJ SHARABHA KALKI LION KING’S ASTRO SPACE ZODIAC SLIDESHOW...
 
MY SCARJO123 SRUTHIVKV.pdf
MY SCARJO123 SRUTHIVKV.pdfMY SCARJO123 SRUTHIVKV.pdf
MY SCARJO123 SRUTHIVKV.pdf
 
MR. MEGAONE KALKI LION KING ZODIAC VS STARS KA SULTAN GANDHI_15081988_3008208...
MR. MEGAONE KALKI LION KING ZODIAC VS STARS KA SULTAN GANDHI_15081988_3008208...MR. MEGAONE KALKI LION KING ZODIAC VS STARS KA SULTAN GANDHI_15081988_3008208...
MR. MEGAONE KALKI LION KING ZODIAC VS STARS KA SULTAN GANDHI_15081988_3008208...
 
MR.MULTIVERSAL COLOR PhotoS Album SERIES - Once More Plz.pptx
MR.MULTIVERSAL COLOR PhotoS Album SERIES - Once More Plz.pptxMR.MULTIVERSAL COLOR PhotoS Album SERIES - Once More Plz.pptx
MR.MULTIVERSAL COLOR PhotoS Album SERIES - Once More Plz.pptx
 
Document Library Folder Operations User Guide
Document Library Folder Operations User GuideDocument Library Folder Operations User Guide
Document Library Folder Operations User Guide
 
Step by Step Personal Drive to One Drive Migration using SPMT
Step by Step Personal Drive to One Drive Migration using SPMTStep by Step Personal Drive to One Drive Migration using SPMT
Step by Step Personal Drive to One Drive Migration using SPMT
 
PDrive Validation Status Documentation
PDrive Validation Status DocumentationPDrive Validation Status Documentation
PDrive Validation Status Documentation
 
Total ODFB Migration Process through SPMT Tool
Total ODFB Migration Process through SPMT ToolTotal ODFB Migration Process through SPMT Tool
Total ODFB Migration Process through SPMT Tool
 
Mover Migration from Box to One drive
Mover Migration from Box to One driveMover Migration from Box to One drive
Mover Migration from Box to One drive
 
Box vs OneDrive Features Comparison
Box vs OneDrive Features ComparisonBox vs OneDrive Features Comparison
Box vs OneDrive Features Comparison
 
Modern SharePoint Content Management Training
Modern SharePoint Content Management TrainingModern SharePoint Content Management Training
Modern SharePoint Content Management Training
 
Box vs One Drive
Box vs One DriveBox vs One Drive
Box vs One Drive
 

Kürzlich hochgeladen

AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 

Kürzlich hochgeladen (20)

AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

SP Rest API Documentation

  • 1. SP REST API Documentation Table of Contents User Authentication:..............................................................................................................................2 For an Advanced Concept please refer here:....................................................................................2 Simple REST API URL 3 Main Blocks: .....................................................................................................2 Simple REST API URL to Create a Folder:...........................................................................................2 Simple REST API URL to Get a Folder:................................................................................................2 Simple REST API URL to Update a Folder: .........................................................................................2 Simple REST API URL to Remove a Folder:........................................................................................3 Simple REST API URL to Create a File with Content:.........................................................................3 Simple REST API URL to Get a File with Content:..............................................................................3 For getting file based on the name................................................................................................3 For Reading a file content with a given name...............................................................................3 Simple REST API URL to Update the File with Content:....................................................................3 Simple REST API URL to Delete the File:............................................................................................3 Advance REST API Concepts Implementation Section wise: ................................................................4 How to Upload a document in a library: ...........................................................................................4 How to bind attachments from a library:..........................................................................................4 How to Delete a document from a library: .......................................................................................5 How to Create folder/ subfolders in a library:..................................................................................6 Some error request codes from REST API: ............................................................................................6 Quick Reference on SP REST API + PowerShell: ....................................................................................6 Author: Kaveri Veera Bharat Bhushan Target Audience: Anyone who knows SharePoint, REST API, PowerShell concepts etc.
  • 2. SP REST API Documentation User Authentication: It Is handled by the portal.office.com automatically at the time of User Signing which gets reflected across all the Sites/Libraries/Folders/SubFolders/Files etc as it promotes Service Account Authenticate via SharePointOnlineCredentials. Can be further more customized using Item Pane[In Modern SharePoint] & Share Option for establishing Item Level/Folder Level permissions to promote only the required members sharing. For an Advanced Concept please refer here: Access SharePoint Online REST API Via Postman With User Context.docx Simple REST API URL 3 Main Blocks: ➢ Get the URL ready ➢ Metadata info POST ➢ REST Type(GET,PUT,POST,MERGE,DELETE) View the results finally after above REST API URL is properly framed. Simple REST API URL to Create a Folder: <SPSiteURL>/_api/web/<FolderName/LibName> {‘_metadata’:{‘type’:’SP.Folder’},’ ServerRelativeUrl’:’/sites/dev/<LibName>/<FolderName>’} REQUEST TYPE: POST Note: Use Folder name if for creating a Sub-Folder & Lib Name for creating a Folder. Simple REST API URL to Get a Folder: <SPSiteURL>/_api/web/GetFolderByServerRelativeUrl(‘/sites/dev/<LibName>/<FolderNam e>’) $select=Title /_api/web/GetFolderByServerRelativeUrl(‘/sites/dev/<LibName>’)/folders?select= ServerRelativeUrl REQUEST TYPE: GET Simple REST API URL to Update a Folder: <SPSiteURL>/_api/web/GetFolderByServerRelativeURL(‘/sites/dev/<LibName>/<OldFolder Name>’)/ListItemAllFields?$select= FileLeafRef {‘_metadata’:{‘type’:
  • 3. SP REST API Documentation SP.Data.<LibraryInternalName>Item}.’FileLeafRef’:’<NewFolderName>’ } REQUEST TYPE: PUT Simple REST API URL to Remove a Folder: <SPSiteURL>/_api/web/GetFolderByServerRelativeURL(‘/sites/dev/<LibName>/OldFolderN ame’)/recycle REQUEST TYPE: DELETE Simple REST API URL to Create a File with Content: <SPSiteURL>/_api/web/GetFolderByServerRelativeURL(‘/sites/dev/<LibName>’)/Files/add(u rl=’<FileName.txt>’,overwrite=true) “Add Some Text!!” REQUEST TYPE: POST Note: Above Extension could be any type of document like .txt, .doc, .ppt etc. Simple REST API URL to Get a File with Content: For getting all the Files <SPSiteURL>/_api/web/GetFolderByServerRelativeURL(‘/sites/dev/<LibraryName>’)/Files For getting file based on the name <SPSiteURL>/_api/web/GetFolderByServerRelativeURL(‘/sites/dev/<LibraryName>’)/Files(‘d emo.txt’) For Reading a file content with a given name <SPSiteURL>/_api/web/GetFolderByServerRelativeURL(‘/sites/dev/<LibraryName>’)/Files(‘d emo.txt’)/$value REQUEST TYPE: GET Simple REST API URL to Update the File with Content: <SPSiteURL>/_api/web/GetFolderByServerRelativeURL(‘/sites/dev/<LibraryName>’)/Files(‘d emo.txt’)/$value “Add New Content to be updated!” REQUEST TYPE: PUT Simple REST API URL to Delete the File: <SPSiteURL>/_api/web/GetFolderByServerRelativeURL(‘/sites/dev/<LibraryName>’)/Files(‘d emo.txt’)/recycle REQUEST TYPE: DELETE
  • 4. SP REST API Documentation Advance REST API Concepts Implementation Section wise: How to Upload a document in a library: /*********Function to upload files ********/ /** Here I am uploading multiple files by using the attachment Buffer: array which is having multiple file info. If you want to upload single file we can skip the iteration of array on below code. **/ function uploadFile() { $.each(attachmentBuffer, function () { var url = String.format( “{0}/_api/Web/Lists/getByTitle(‘” + attachmentLibraryName + “‘)/RootFolder/folders(‘” + folderName + “‘)/Files/Add(url='{1}’, overwrite=true)”, appWebUrl.split(‘appname’)[0], this.File.name); /* attachmentLibraryName , folderName is the library name which is from constant entry. this.File.name dynamic name we can directly pass file.name */ $.ajax({ url: url, method: “POST”, contentType: “application/json;odata=verbose”, processData: false, data: this.File, async: false, headers: { “Accept”: “application/json; odata=verbose”, “X-RequestDigest”: formDigestValues }, success: function () { onUploadSucess(); }, error: function () { onUploadFailure(); } }); }); } How to bind attachments from a library: /*********Function to bind the attachments from document library ********/ function getAttachments() { var getDocumentsUrl = String.format( “{0}/_api/web/GetFolderByServerRelativeUrl(‘” + attachmentLibraryUrl + “” + “/” +
  • 5. SP REST API Documentation folderName + “‘)/files?$select=Name,ServerRelativeUrl”, appWebUrl.split(‘appname’)[0]); $.ajax({ url: getDocumentsUrl, type: ‘GET’, headers: { “Accept”: “application/json; odata=verbose”, “content-type”: “application/json;odata=verbose” }, success: function (data) { $.each(data.d.results, function (i, result) { /* The below code which will disply the files from the folder */ $(“[id^=’fileAttachments’]”).append(‘<a href=”‘ + result.ServerRelativeUrl + ‘” target=”_blank”>’ + result.Name + ‘</a><br/>’); }); }, error: function onGetFilesFailure(response) { console.log(response.status + ‘ ‘ + response.statusText); } }); } How to Delete a document from a library: /*********Function to delete a document ********/ $.ajax( { "url": "/sites/test/_api/web/getfilebyserverrelativeurl('/sites/test/Shared%20Documents/Airplane Logo.jpg')", "method": "POST", "headers": { "accept": "application/json;odata=verbose", "content-type": "application/json;odata=verbose", "X-HTTP-Method": "DELETE", "If-Match": "*", "X-RequestDigest": "yourRequestDigestGoesHere" }, "success" = successfunction, "error" = errorfunction } );
  • 6. SP REST API Documentation How to Create folder/ subfolders in a library: /*********Function to create the folder ********/ function createFolder() { var docCreationUrl = appWebUrl.split(‘appname’)[0]; /* Here i am doing manipulation at host web level, as per the my requirement i am using the above url instead of _spPageContextInfo.siteAbsoluteUrl */ var serverRelativeUrl = docCreationUrl.slice(docCreationUrl.indexOf(‘/’) + 2); serverRelativeUrl = serverRelativeUrl.slice(serverRelativeUrl.indexOf(‘/’) + 0); var docLibURL = { ‘__metadata’: { ‘type’: ‘SP.Folder’ }, ‘ServerRelativeUrl’: serverRelativeUrl + “/” + ‘attachmentLibraryUrl’ + “/” + ‘folderName’ }; /* attachmentLibraryUrl is the library url */ return $.ajax({ url: appWebUrl.split(‘appname’)[0] + “/_api/web/folders”, type: “POST”, contentType: “application/json;odata=verbose”, data: JSON.stringify(docLibURL), headers: { “Accept”: “application/json;odata=verbose”, “X-RequestDigest”: formDigestValues /* formDigestValues is the request digest value like $(“#__REQUESTDIGEST”).val() **/ }, success: function () { onAttachmentSucess(); }, error: function () { onAttachmentFailure(); } }); } Some error request codes from REST API: Http 404 – You queried an invalid URL Http 400 – Bad request, the URL was right but you sent an invalid rest call Http 412 – Concurrency violation Http 500 – Genuine server side error, error will include correlation ID Quick Reference on SP REST API + PowerShell: https://collab365.community/tutorial-create-read-update-delete-files-sharepoint-using- rest/