Friday, September 5, 2014

SharePoint 2013 - Get Add Remove - My Tags or SocialTag using javascript service call


SharePoint 2013 - Get Add Remove - My Tags - SocialTag - avaliable in socialdataframe.aspx ( Tags and Note Board ) - using service call  /_vti_bin/socialdatainternalservice.json 

GetTags:
$.ajax({
                                                           url: "/_api/contextinfo",
                                                           type: "POST",
                                                           contentType: "application/x-www-url-encoded",
                                                           dataType: "json",
                                                           headers: { "Accept": "application/json; odata=verbose", },
                                                           success: function (data) {
                                                               if (data.d) {
                                                                   var digest = data.d.GetContextWebInformation.FormDigestValue;
alert(digest);
                                                                   $.ajax({
                url: "/_vti_bin/socialdatainternalservice.json/GetSocialTagInternal",
                dataType: 'json',
                type: 'POST',
                data: '{"targetPage":"http://vddp23g-6c4153b:100/us/spc-do-01/eFileLibrary/PX230230","maximumItemsToReturn":"12"}',
                contentType: 'application/json; charset=utf-8',
                headers: {
                                                                           "accept": "application/json;odata=verbose",
                                                                           "X-RequestDigest": digest,
                                                                       },
                success: function (data) {
alert('success');
                     console.log(JSON.stringify(data));
                },
                error: function (err) {

                    alert(JSON.stringify(err));
                }
            });
                                                               }
                                                           },
                                                           error: function (err) {
                                                               alert(JSON.stringify(err));
                                                           }
                                                       });
                                                      
                                                       }


AddTag:
(Replace following in the above ajax call)
url: "/_vti_bin/socialdatainternalservice.json/ManageTagInternal",
                dataType: 'json',
                type: 'POST',
                data: '{"targetPage":"","title":"","changes":[{"ChangeType":0,"TermID":"d5f86d42-4f82-4574-9318-4559b4f5d3a9","Term":"spotlight","IsPrivate":false}],"maximumItemsToReturn":"12"}',


RemoveTag:
(Replace following in the above ajax call)
url: "/_vti_bin/socialdatainternalservice.json/ManageTagInternal",
                dataType: 'json',
                type: 'POST',
                data: '{"targetPage":"","title":"","changes":[{"ChangeType":2,"TermID":"350ba065-5119-4b9a-8d07-6e74d603d939","Term":"tamarind","IsPrivate":false}],"maximumItemsToReturn":"12"}',

No comments:

Post a Comment