Add Quick Launch Link To SharePoint 2013 Site Using REST API

Introduction

In this article, I have explored how to add links represented as headings in the Quick Launch area of the user interface using REST API. Here, we tried to add custom navigation node corresponding to the links in the Quick Launch area of the site using REST API using jQuery.

Prerequisites -

REST API QuickLaunch EndPoint to use in Add_ins -

/_api/web/Navigation/QuickLaunch

Scenario

I have created the host site and have by default added multiple Quick Launch navigation nodes. Now, let’s say we want to add one Custom navigation nodes ‘’Notebook” in the Quick Launch (i.e., Left Navigation).

SharePoint

Objective

I have added one custom navigation node ‘’ Notebook” to the Quick Launch (i..e Left Navigation) on button click.

Use the procedure given below.

Step 1

Navigate to your SharePoint 2013 site.

Step 2

From this page, select Site Actions | Edit Page.

Edit the page, go to the "Insert" tab in the ribbon and click "Web Part" option. In the Web Parts picker area, go to the "Media and Content" category, select the Script Editor Web Part, and press the "Add" button.

Step 3

Once the Web Part is inserted into the page, you will see an "EDIT SNIPPET" link; click it. You can insert HTML and/or JavaScript, as shown below.

  1. <script type="text/javascript" src="../.../SiteAssets/Script/jquery-1.10.2.js"></script>    
  2.     <script type="text/javascript">  
  3.         $(document).ready(function ($) {  
  4.   
  5.             $("#createQuickLaunch").click(function () { createQuickLaunch() });  
  6.   
  7.         });  
  8.         //Create a Quicklaunch Navigation  
  9.         function createQuickLaunch() {  
  10.             var endPointUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/navigation/QuickLaunch";  
  11.             var headers = {  
  12.                 "accept""application/json;odata=verbose",  
  13.                 "content-Type""application/json;odata=verbose",  
  14.                 "X-RequestDigest": jQuery("#__REQUESTDIGEST").val()  
  15.             }  
  16.             var call = jQuery.ajax({  
  17.                 url: endPointUrl,  
  18.                 type: "POST",  
  19.                 data: JSON.stringify({  
  20.                     "__metadata": { type: "SP.NavigationNode" },  
  21.                     'IsExternal'true,  
  22.                     'Title'"Notebook",  
  23.                     'Url'"http://www.testnotebook.com"  
  24.                 }),  
  25.                 headers: headers  
  26.             });  
  27.             call.done(successHandler);  
  28.             call.fail(failureHandler);  
  29.         }  
  30.         function successHandler(data, textStatus, jqXHR) {  
  31.             SP.UI.Notify.addNotification("Navigation created Successully"false);  
  32.         }  
  33.         function failureHandler(errorMessage) {  
  34.             alert("Request Failed: unable to Navigation: " + JSON.stringify(errorMessage));  
  35.         }  
  36.     </script>  

Final out Put

Click " Create Navigation" button.

SharePoint