1

I need to display current User's followed sites under my Wiki Homepage. So, i got the following code written in a followedsites.htm stored under SiteAssets Library and added it to the Home page by a content editor WP :

<html>    
   <head>    
      <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>    


         <script type="text/javascript">  
            var followingManagerEndpoint;  
            var followedCount;  

            var followingEndpoint;    
            var URL;    
            var website;    
            var clientContext;   

            SP.SOD.executeFunc('sp.js', 'SP.ClientContext', loadWebsite);    
            function loadWebsite() {    
               clientContext = SP.ClientContext.get_current();    
               website = clientContext.get_web();    
               clientContext.load(website);    
               clientContext.executeQueryAsync(onRequestSucceeded, onRequestFailed);    
            }    

            function onRequestSucceeded() {   


              URL = website.get_url();    
              followingManagerEndpoint = decodeURIComponent(URL) + "/_api/social.following";   

              getMyFollowedContent();  
           }    

           function onRequestFailed(sender, args) {    
             console.log('Error: ' + args.get_message());    
             $("#Follow").html("<p>Aucun site suivi</p>");  

           }   

           // Get the content that the current user is following.  
           // The "types=14" parameter specifies all content types  
           // (documents = 2 + sites = 4 + tags = 8).  
          function getMyFollowedContent() {  

            $.ajax( {  
                 url: followingManagerEndpoint + "/my/followed(types=4)",  
                 headers: {   
                     "accept": "application/json;odata=verbose"  
                 },  
                 success: followedContentRetrieved,  
                 error: requestFailed  
           });  
        }  

        // Parse the JSON data and iterate through the collection.  


        function followedContentRetrieved(data) {  
            var stringData = JSON.stringify(data);  
            var jsonObject = JSON.parse(stringData);   
            var types = {  
              1: "document",  
              2: "site",  
              3: "tag"   
           };  

           var followedActors = jsonObject.d.Followed.results;   
           var followedList = "<ul class='followedsites'>";  

           for (var i = 0; i < followedActors.length; i++) {  
              var actor = followedActors[i];  
              followedList += "<li> <a href='"+actor.Uri+"' title='"+actor.Name+"'> "+ actor.Name +" </a> </li>";;  
           }   
           $("#Follow").html(followedList + "</ul>");   
        }  

        function requestFailed(xhr, ajaxOptions, thrownError) {  
          alert('Error:\n' + xhr.status + '\n' + thrownError + '\n' + xhr.responseText);  
        }  

      </script>    
   <title></title></head>    
<body>    
<div id="Follow"></div>    
</body>    
</html>  

But i am getting the following error, displayed in a alert pop-up :

Error popup displayed when trynig to get user's followed sites

This is in french, so i'll try and translate it :

Error : 500 Internal Server Error {"error":{"code":"12, Microsoft.Office.Server.Social.SPSocialException","message":{"lang":"fr-FR","value":"There is no personnal site for actual user, and you should not try to create one. Intern type name : Microsoft.Office.Server.UserProfiles/SocialDataStoreException. Internal error code :2"}}}

I don't really know what this does mean, plus i've specified to throw the error not in a alert pop-up, but in the console logs. But it is displayed for me AND for every users of my client...

I did not found what was the Internal Error code = 2 meaning, nor code 12...

Do you have any idea of what is happening? Even few tips, or some ways i could digg in, getting some tracks...

Thanks a lot for your time !

  • I tried the exact code (minus the html\head tags) and it worked fine... Do you get an exception when you access the url: /_api/social.following/my/followed(types=4) – Bunzab Apr 28 '16 at 10:02
  • Hello @Bunzab, I tried the following URL : <mySiteCollection>/_api/social.following/my/followed(types=4) and i get a error 500 again. How did you use the code without the html tags ? I'm curious, maybe i could try it too – Gaelle Apr 28 '16 at 10:08
2

Based on the error status, SharePoint is saying no personal site exists for the user. Did you check whether Mysites is properly configured and you are able to access the page? I have faced the same issue and resolved it by recreating the User Profile in my dev UPA

You can also try some of the solutions proposed here https://social.technet.microsoft.com/Forums/office/en-US/5549ecb4-dd50-49bf-a1d6-3b504dd7a8bc/sharepoint-2013-problem-user-personal-site-never-created-clicking-skydrivenewsfeedor-follow?forum=sharepointgeneral

You can directly check the return value from your Rest Api by pasting the url in your browser

<sitecollectionurl>/_api/social.following/my
  • Thanks @Karvannan, i tested the URL you're giving me but i still get a 500 error. – Gaelle Apr 28 '16 at 12:23
  • This confirms that there is some problem in mysites configuration for the user making the call. Try to resolve the errors by following some of the solutions proposed in the shared link – Karvannan Apr 29 '16 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.