Updating Global and Current Navigation of a SP site Using REST Api

The following is the code to add the Links into the SP site using Javascript.It invokes the POST method and so a metadata has to be passed before the AJAX call.


function createNavigation() {

var item=
                      “__metadata”: { type: “SP.NavigationNode” },
                      ‘IsExternal’: true,
                      ‘Title’: “blog”,//Name of the LINK to be added and the URL 
                      ‘Url’: “http://www.rmanimaran.wordpress.com”
                 url: “Yoursitename/_api/web/navigation/TopNavigationbar”,

                //In Case of Current Navigation the URL changes to QuickLaunchBar
               type: “POST”,
                contentType: “application/json;odata=verbose”,
                data: JSON.stringify(item),
               headers: {
              “Accept”: “application/json; odata=verbose”,
              “X-RequestDigest”: $(“#__REQUESTDIGEST”).val()
               success: function (data) {
               alert(‘Item added successfully’);
               error: function (error) {
               alert(“Error: “+ JSON.stringify(error));


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s