As a SharePoint developer, you should know how to use the REST API in SharePoint. In this tutorial, I will explain how to work with SharePoint REST API, both on-premises and online versions.
I will also show a few examples of using the REST API in SharePoint Online and On-Premises. Most of the examples will work on both versions.
What is SharePoint REST API?
SharePoint REST API (Representational State Transfer Application Programming Interface) allows developers to interact with SharePoint data using simple HTTP requests. It provides a standardized way to perform Create, Read, Update, and Delete (CRUD) operations on SharePoint resources such as site, list or libraries, etc.
REST API is built on OData (Open Data Protocol) standards, which makes it consistent and predictable to use.
The beauty of REST API is its simplicity – you can access SharePoint data using standard HTTP methods like GET, POST, PUT, and DELETE.
How the SharePoint REST API works
You can interact remotely with SharePoint sites using the REST API in SharePoint. You can use any technology that supports REST web requests. You need to construct a RESTful HTTP request using the Open Data Protocol (OData) standard.
For example, you can use the following REST endpoint to get the SharePoint list by title.
https://tsinfotechnologies.sharepoint.com/sites/enjoysharepoint/_api/lists/getbytitle('Projects')Similarly, if you want to retrieve the same list items using the Rest API in SharePoint Online, you have to construct the Rest endpoint URL:
https://{site_url}/_api/lists/getbytitle('Projects')/items
Example:
https://tsinfotechnologies.sharepoint.com/sites/enjoysharepoint/_api/lists/getbytitle('Projects')/itemsFollow the diagram below to understand how the REST API works in SharePoint.

Here your application will send an HTTP request and client.svc web service handles the request which internally calls the Server object model to retrieve data from the Content database.
And then it sends the response in either Atom or JavaScript Object Notation (JSON) format which your client application should able to parse.
Check out Create Remote Event Receiver in SharePoint Online
REST API HTTP commands for SharePoint
You should build the endpoints to perform any operation in SharePoint using the REST API. Here are a few things you should know about this.
- If you want to read data from the SharePoint site, then you should use an HTTP GET request.
- Example: reading list items
- Similarly, if you want to add or update, you should use an HTTP POST request. For POST operations, any properties that are not required are set to their default values. If you attempt to set a read-only property as part of a POST operation, the service returns an exception.
- Example: Create a list or library
- Use PUT and MERGE operations to update existing SharePoint objects. Any service endpoint representing an object property set operation supports PUT and MERGE requests.
- Setting properties is optional for MERGE requests; any properties that you do not explicitly set retain their current state.
- For PUT commands, however, any properties you do not explicitly set are set to their default properties. In addition, if you do not specify all required properties in object updates when using HTTP PUT commands, the REST service returns an exception.
- Example: Update a list or library Title or Description
- If you want to delete, you should request an HTTP DELETE.
- Example: Delete a SharePoint List or Library
Typically, endpoints representing read operations map to HTTP GET commands, endpoints representing update operations map to HTTP POST commands, and endpoints representing update or insert operations map to HTTP PUT commands.
If you are doing a POST request in the REST API in SharePoint, you must pass the form digest value in the X-RequestDigest header. Even if you are using the Rest API code in a script editor web part or if you are using it in a SharePoint Add-in, you need to
You can do this by writing the below code:
"X-RequestDigest": $("#__REQUESTDIGEST").val()Here are a few examples of SharePoint REST API endpoints.
- List: https://server/site/_api/web/lists
- Site: https://server/site/_api/site
- Web: https://server/site/_api/web
- User Profile: https://server/site/_api/Sp.UserProfiles.PeopleManager
- Search: https://server/site/_api/search
- Publishing: https://server/site/_api/publishing
A few more SharePoint Rest API end point examples:
- https://{site url}/_api/web/title : Get the title of the web or site
- https://{site url}/_api/lists : Retrieve all the lists and libraries presented on the SharePoint site
- https://{site url}/_api/lists/getbytitle(‘listname’)/items: Retrieve all the items from a particular list
- https://{site url}/_api/lists/getbytitle(‘listname’)?select=Title : Retrieve Title of the SharePoint list
Check out SharePoint Online jsom examples
SharePoint Rest API Examples
Let me show you a few practical examples of REST API in SharePoint. These will work with both SharePoint Online and On-Premises versions.
I used a SharePoint script editor web part to put the code for all the examples.
Get User Display Name using the REST API in SharePoint
Let me show you how to get the user’s display name using the REST API in SharePoint.
Here, I am displaying the display name of the logged-in user in SharePoint using Rest API when a button is clicked.
<input type="button" id="btnClick" value="Click Here"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(function(){
$("#btnClick").click(function(){
var userid = _spPageContextInfo.userId;
var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/getuserbyid(" + userid + ")";
var requestHeaders = { "accept": "application/json;odata=verbose" };
$.ajax({
url: requestUri,
contentType: "application/json;odata=verbose",
headers: requestHeaders,
success: onSuccess,
error: onError
});
function onSuccess(data, request) {
var userinfo = data.d;
alert ('Display Name: '+ userinfo.Title);
}
function onError(error) {
alert("error");
}
});
});
</script>The Title property displays the user’s display name. Similarly, you can use the Email property to retrieve the logged user’s email ID and the LoginName property to retrieve the user’s login name in SharePoint.
Check out SharePoint get current user id, name, email, display name programmatically
Get SharePoint Site Language using REST API
Here, I will show you how to get alternative languages using the REST API in SharePoint Online. You can see the alternative language from Site Settings -> Language Settings, which is under the “Site Administration” section.

Here, you can use the REST API code below to get a SharePoint site’s language.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(function(){
$("#btnClick").click(function(){
var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/supportedUILanguageIds";
$.ajax({
url: requestUri,
type: "GET",
headers: {
"accept":"application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest":$("#_REQUESTDIGEST").val()
},
success: onSuccess,
error: onError
});
function onSuccess(data) {
var value = data.d.SupportedUILanguageIds.results;
alert(value);
for (var i=0; i<value.length; i++) {
alert(value[i]);
}
}
function onError(error) {
alert('Error');
}
});
});
</script>
<input type="button" id="btnClick" value="Get AlternateLanguages"/>
This is how to get alternate languages from language settings in SharePoint using the REST API.
Check out SharePoint CSOM
Get All SharePoint Lists and Libraries using REST API
Now, let me show you how to get all SharePoint lists and libraries using the REST API. You can use the code in both SharePoint Online and on-premises versions.
In this example, I used the HTML code to add a button. When the button is clicked, we display all the lists and libraries.
Both the HTML code and the rest API code will be put inside a script editor web part which we will add inside a web part page.
Below is the HTML Code:
<div>
<input type="button" id="btnSubmit" value="Get All Lists" />
</div>
<div id="divResults"></div>
<div id="divAllLists"></div>Rest API Code:
Here, I have used _spPageContextInfo.webAbsoluteUrl to get the absolute URL of the SharePoint site we used in the REST endpoint.
Then in the onQuerySucceeded method, we are retrieving all the lists in a for-each loop. And we are binding the data into the <div id=”divAllLists”></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(function () {
$("#btnSubmit").on("click", function () {
getAllLists();
});
});
function getAllLists() {
var fullUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists";
$.ajax({
url: fullUrl,
type: "GET",
headers: {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
},
success: onQuerySucceeded,
error: onQueryFailed
});
}
function onQuerySucceeded(data) {
var listItemInfo = ";
$.each(data.d.results, function (key, value) {
listItemInfo += 'Title: ' + value.Title + '<br />';
});
$("#divAllLists").html(listItemInfo);
}
function onQueryFailed() {
alert('Error!');
}
</script>Once you save the code and click on the button, it will display all the lists and libraries from the SharePoint site.

Check out SharePoint REST API Create List Item
Delete SharePoint list Item using REST API
Here is an example to delete a SharePoint list item using the REST API.
Here, I have a button on a web part page. When the user clicks on that button, the list item is deleted.
Here, you will see there are 3 items in the list, like below. Using the REST API, we will delete the 2nd item from the list.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(function(){
$("#btnClick").click(function(){
var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getByTitle('BijayTestList')/getItemById(2)";
$.ajax({
url: requestUri,
type: "DELETE",
headers: {
"accept":"application/json",
"X-RequestDigest":$("#_REQUESTDIGEST").val(),
"IF-MATCH":"*"
},
success: onSuccess,
error: onError
});
function onSuccess(data) {
alert(data+ ‘ Item Deleted’);
}
function onError
(error) {
alert(JSON.stringify(error));
}
});
});
</script>
<input type="button" id="btnClick" value="Click Here"/>Now you can see the list will have only two items in the SharePoint Online list.

This is how to delete a list item using the REST API in SharePoint Online or SharePoint on-premises.
Check out How to Create SharePoint List Items Using Power Automate?
Delete SharePoint list using REST API
Here is an example of deleting a SharePoint list using the REST API.
Here, I have a button on a SharePoint web part page. When a user clicks on that button, the SharePoint list is deleted.
Copy the code below and paste it inside a script editor web part. Here, we are retrieving the list by using the getByTitle method.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(function(){
$("#btnClick").click(function(){
var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getByTitle('Columns_List')";
$.ajax({
url: requestUri,
type: "DELETE",
headers: {
"accept":"application/json",
"X-RequestDigest":$("#_REQUESTDIGEST").val(),
"IF-MATCH":"*"
},
success: onSuccess,
error: onError
});
function onSuccess(data) {
alert('List Deleted');
}
function onError
(error) {
alert(error);
}
});
});
</script>
<input type="button" id="btnClick" value="Click Here"/>This is how to delete a list using the REST API in SharePoint.
Check out Delete All Items in the SharePoint List Using Power Automate
Create a SharePoint Group using the REST API
I will show you how to create a SharePoint group using the REST API in this example. I have created an HTML button, and once you click on the button, the SharePoint group will be created.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(function(){
$("#btnClick").click(function(){
var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/sitegroups";
$.ajax({
url: requestUri,
type: "POST",
data:JSON.stringify({'__metadata': { 'type': 'SP.Group' }, 'Title': 'MyTest Group', 'Description':'My Group Description'}),
headers: {
"accept":"application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest":$("#_REQUESTDIGEST").val()
},
success: onSuccess,
error: onError
});
function onSuccess(data) {
alert('Group created successfully');
}
function onError(error) {
alert(JSON.stringify(error));
}
});
});
</script>
<input type="button" id="btnClick" value="Create SharePoint Group"/>Once you click on the button, the group will be created like below:

Check out SharePoint REST API Create Folder
Update SharePoint Group using REST API
Let us see how to update SharePoint group details using the rest api in SharePoint. Below is the complete REST API code.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(function(){
$("#btnClick").click(function(){
var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/sitegroups(3838)";
$.ajax({
url: requestUri,
type: "POST",
data:JSON.stringify({'__metadata': { 'type': 'SP.Group' }, 'Description':'My New Updated Group Description'}),
headers: {
"content-type": "application/json;odata=verbose",
"X-HTTP-Method":"MERGE"
},
success: onSuccess,
error: onError
});
function onSuccess(data) {
alert('Group description updated successfully');
}
function onError(error) {
alert(JSON.stringify(error));
}
});
});
</script>
<input type="button" id="btnClick" value="Update SharePoint Group Details"/>This is how to update the SharePoint group details using the REST API.
Get All Users from a SharePoint Group using REST API
I will show you how to get all users from a SharePoint permission group using the REST API. Here is the complete REST API code.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(function(){
$("#btnClick").click(function(){
var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/sitegroups(2544)/users";
$.ajax({
url: requestUri,
type: "GET",
headers: {
"accept":"application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest":$("#_REQUESTDIGEST").val()
},
success: onSuccess,
error: onError
});
function onSuccess(data) {
var items = data.d.results;
var results=";
for (var i = 0; i < items.length; i++) {
results+=items[i].LoginName+ " : " + items[i].Email +'\n';
}
alert(results);
}
function onError(error) {
alert(JSON.stringify(error));
}
});
});
</script>
<input type="button" id="btnClick" value="Get All Users From SharePoint Group"/>This way, you can get all the users from a SharePoint group using the REST API.
Check out Display Microsoft 365 Group Members in a Power Apps Dropdown
Add a User to a SharePoint Group using REST API
In this example, I will show you how to add users to a SharePoint group using the REST API.
Here is the complete code.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(function(){
$("#btnClick").click(function(){
var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/sitegroups(2544)/users";
$.ajax({
url: requestUri,
type: "POST",
data:JSON.stringify({‘__metadata’: { ‘type’: ‘SP.User’ }, ‘LoginName’: ‘domain\\username’}),
headers: {
"accept":"application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest":$("#_REQUESTDIGEST").val()
},
success: onSuccess,
error: onError
});
function onSuccess(data) {
alert(‘User Added’);
}
function onError(error) {
alert(JSON.stringify(error));
}
});
});
</script>
<input type="button" id="btnClick" value="Add User to SharePoint Group"/>Check out SharePoint REST API Order by, Filter, Pagination, and Select
Add Bulk Users to SharePoint Group from Excel using Rest API
In this example, I will show you how to add bulk users from an Excel spreadsheet to a SharePoint group using the REST API.
I have an Excel file with one column for Users containing the user names.
You can upload the Excel sheet to the SharePoint SiteAssets library.
Below is the code to add bulk users to SharePoint groups using the REST API:
<input type=button id="btnClick" value='Click Here' onclick="AddUserFromExcel();" />
<script language="javascript" type="text/javascript">
var i;
var l;
var a1;
var user;
var spGroup;
function AddUserFromExcel()
{
l=1;
var Excel;
Excel = new ActiveXObject(“Excel.Application");
Excel.Visible = false;
for(l=1;l<3;l++)
{
a1=Excel.Workbooks.Open(“http://SiteURL/SiteAssets/Users.xlsx?Web=1").ActiveSheet.Cells(l,1).Value;
var a4="Domain\\"+a1;
var clientContext = new SP.ClientContext.get_current();
var web=clientContext.get_web();
var siteGroups = clientContext.get_web().get_siteGroups();
spGroup=siteGroups.getById(4990);
user=web.ensureUser(a4);
var userCollection=spGroup.get_users();
userCollection.addUser(user);
clientContext.load(user);
clientContext.load(spGroup);
clientContext.executeQueryAsync(onQuerySucceeded, onQueryFailed);
function onQuerySucceeded()
{
alert('success');
}
function onQueryFailed()
{
alert('Request failed.');
}
}
}
</script>This is how to add bulk users to a SharePoint group using the REST API.
Check out Create an Excel File from SharePoint list Items using Power Automate
Remove a User from a SharePoint Group using REST API
In this SharePoint REST API example, I will show you how to remove a user from a SharePoint group. You can remove a user by login name or by user ID.
Below is the complete code.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(function(){
$("#btnClick").click(function(){
var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/sitegroups(2544)/users/removeByLoginName(‘domain\\username’)";
$.ajax({
url: requestUri,
type: "POST",
success: onSuccess,
error: onError
});
function onSuccess(data) {
alert(‘User Removed successfully’);
}
function onError(error) {
alert(JSON.stringify(error));
}
});
});
</script>
<input type="button" id="btnClick" value="Remove User from SharePoint Group"/>Similarly, if you want to remove a user by ID then the rest URL will be like below:
var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/sitegroups(2544)/users/removebyid(10)";Here, 10 is the ID of the user.
This is how to remove a user from a SharePoint group using the REST API by using the login name or user ID in SharePoint Online.
Check out SharePoint Rest API Crud Operations
Get Current User Groups using SharePoint REST API
In this example, I will show you how to get the current user groups using the SharePoint REST API. This will display all the SharePoint groups that the current user is a member of.
Below is the complete code:
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () { getCurrentUser(); });
function getCurrentUser() {
getUserWebPermissionREST();
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/CurrentUser",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function (data) {
getCurrentUserGroupColl(data.d.Id);
},
error: function (data) {
failure(data);
}
});
}
function getCurrentUserGroupColl(UserID) {
$.ajax
({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/GetUserById(" + UserID + ")/Groups",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function (data) {
/* get all group’s title of current user. */
var results = data.d.results; var InnrHtmlgrp = "<ul>";
for (var i = 0; i < results.length; i++) {
InnrHtmlgrp += "<li>" + results[i].Title + "</li>";
}
$("#Group").append(InnrHtmlgrp + "</ul>");
}
});
}
</script>
<strong>security Group Name:</strong>
<div id="Group"></div>
In the above, you can see the group names to which the current user belongs.
Create a File using the REST API in SharePoint
Now, we will see how to create a file using the REST API in SharePoint Online.
In this particular example, let us take a textbox, multiple textboxes, and a button in an HTML form. Here, the user will give a name for the file and put the file content in the multiline textbox. Then, the user can submit the button, which will create a text file.
HTML Code:
<div id="CreateFile">
<div>
<strong>Enter Document Name:</strong>
<br />
<input type="text" id="txtDocumentTitle" />
</div>
<div>
<strong>Enter Document Content:</strong>
<br />
<textarea cols="20″ id="txtDocumentContent"></textarea>
</div>
<br />
<input type="button" id="btnSubmit" value="Submit" />
</div>
<div id="divResults"></div>Rest API Code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(function () {
bindButtonClick();
});
function bindButtonClick() {
$("#btnSubmit").on("click", function () {
createDocument();
});
}
function createDocument() {
var docTitle = $("#txtDocumentTitle").val() + ".txt";
var docContent = $("#txtDocumentContent").val();
var fullUrl = _spPageContextInfo.webAbsoluteUrl+ "/_api/web/GetFolderByServerRelativeUrl('Shared Documents')/Files/add(url='" + docTitle +"',overwrite=true)";
$.ajax({
url: fullUrl,
type: "POST",
data: docContent,
headers: {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
},
success: onQuerySucceeded,
error: onQueryFailed
});
}
function onQuerySucceeded() {
$("#divResults").html("Document successfully created!");
}
function onQueryFailed() {
alert('Error!');
}
</script>Once we save the page, you can see a page like below, wherethe user can give a title for the file, then the user can put content in the content textbox, and then the user can click on the submit button, which will create a file inside the document library like below:

Now you can check in the SharePoint document library, where you can see that the file was created in the document library in SharePoint.

This is how to create a document using the REST API in SharePoint.
Check out Create an Excel File from SharePoint list Items using Power Automate
Delete a File using the REST API in SharePoint
Now, we will see how to delete a file using the REST API in SharePoint.
In this example, we have a file named Bijay.txt inside the Documents document library. We will delete the file using the REST API.
The document library looks like this:

Here, we have created an HTML input box and a submit button. The user will enter a name in the textbox and click the Delete File button, which will delete the file from the document library.
Below is the HTML Code:
Here, let us add both the HTML and REST API code inside a script editor web part inside a web part page.
HTML Code:
<div id="DeleteFile">
<div>
<strong>File Name to Delete:</strong>
<br />
<input type="text" id="txtDocumentTitle" />
</div>
<br />
<input type="button" id="btnSubmit" value="Delete File" />
</div>
<div id="divResults"></div>Below is the REST API code. When we click the button, we call the deleteDocument() method.
Rest API Code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(function () {
bindButtonClick();
});
function bindButtonClick() {
$("#btnSubmit").on("click", function () {
deleteDocument();
});
}
function deleteDocument() {
var docTitle = $("#txtDocumentTitle").val() + ".txt";
var siteUrl = _spPageContextInfo.webAbsoluteUrl;
var webRelUrl = _spPageContextInfo.webServerRelativeUrl;
var fullUrl = siteUrl + "/_api/web/GetFileByServerRelativeUrl('" + webRelUrl +"/Shared Documents/" + docTitle +"')";
$.ajax({
url: fullUrl,
type: "POST",
headers: {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"X-HTTP-Method": "DELETE",
"IF-MATCH": "*"
},
success: onQuerySucceeded,
error: onQueryFailed
});
}
function onQuerySucceeded() {
$("#divResults").html("Document successfully deleted!");
}
function onQueryFailed(sender, args) {
alert('Error!');
}
</script>Once you save the code and refresh the page, it will appear as below. The user can give the file name and click on the Delete File button, which will delete the file from the document library in SharePoint.

Now, if we check the document library, the file is not there, like below:

Like this, we can delete a file using the REST API in SharePoint.
Check out How to Delete File From SharePoint Using Power Automate?
Send Email using REST API using SharePoint
In this example, I have created a sample Contact Us HTML form. There will be three fields and a button. When you click the button, you will send an email.
I have added the script below in a SharePoint script editor web part.
<h1>Contact Us</h1><br/>
Name: <br/>
<input type="text" name="myname" id="myname" placeholder="Enter your Name"/><br/>
Email: <br/>
<input type="text" name="myemail" id="myemail" placeholder="Enter your Email Address"/><br/>
Message: <br/>
<textarea rows="4" cols="50" id="mymessage"></textarea><br/><br/>
<button type="button" id="fbutton">Send Message</button>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("#fbutton").click(function(){
var sitetemplateurl = _spPageContextInfo.webServerRelativeUrl + "_api/SP.Utilities.Utility.SendEmail";
var name = $("#myname").val();
var from = $("#myemail").val();
var msg = 'From: ' + name + '<br/><br/>' + 'Email: ' + from + '<br/><br/><br/>' + $("#mymessage").val();
$.ajax({
contentType: 'application/json',
url: sitetemplateurl,
type: "POST",
data: JSON.stringify({
'properties': {
'__metadata': { 'type': 'SP.Utilities.EmailProperties' },
'From': from,
'To': { 'results': ['[email protected]'] },
'Body': msg,
'Subject':'New Email From SharePoint Online using RestAPI'
}
}),
headers: {
"Accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
},
success: function (data) {
alert('Message sent successfully !!!');
$("#myname").val(");
$("#myemail").val(");
$("#mymessage").val(");
},
error: function (err) {
alert(JSON.stringify(err));
}
});
});
});
</script>Once save the page, the page will appear like below:

After saving the page and clicking on the button, the email will go like this:

This is how to send an email using the REST API in SharePoint.
Conclusion
I hope you understand now how to work with the REST API in SharePoint Online. I have also provided a few examples of the SharePoint REST API.
You may also like:
- Save site as template in SharePoint
- SPServices in SharePoint
- How to Get Current User using SharePoint Rest API?

After working for more than 18 years in Microsoft technologies like SharePoint, Microsoft 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (12 times). I have also worked in companies like HP, TCS, KPIT, etc.
Hi, If SharePoint REST services are invoked from a custom web application how would a user authentication and authorisation takes place for the REST service call? Does it require user-only policy and simply need to provide user access token? This user has already authenticated in the custom web application using 3rd-party SSO solution.
Hello, Thank you very much for this. Is there a way to load trigger instead of click?
what will be the value for _spPageContextInfo.webAbsoluteUrl
Plz help me file upload method
get birthday from people picker column REST API