Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 25064

Follow document renders SPSocialException Internal error code 11

$
0
0

I'm writing a method to programmatically follow or unfollow documents in SharePoint 2013. The idea is to call the method providing the path to the document, the user and a bool indicating if we're turning following on or off for the particular document and user.

The problem is that when I call the Follow method (or StopFollowing) on my FollowManager, I get this execption:

SPSocialException was caught

"The operation failed because an internal error occurred. Internal type name: Microsoft.Office.Server.UserProfiles.FollowedContentException. Internal error code: 11."

Here's my code. Everything works fine until the if (follow) clause. The user and document objects are valid, the path exists and is accessible.

private static string FollowOrUnfollowDocument(string absouteEncodedPathDocument, SPUser user, bool follow)
{
    string retval = string.Empty;

    SPSecurity.RunWithElevatedPrivileges(delegate()
    {
        try
        {
            SPServiceContext serverContext = SPServiceContext.GetContext(SPContext.Current.Web.Site);
            UserProfileManager profileManager = new UserProfileManager(serverContext);
            UserProfile profile = profileManager.GetUserProfile(user.LoginName);

            if (profile != null)
            {
                SPSocialFollowingManager followManager = new SPSocialFollowingManager(profile);
                SPSocialActorInfo newActor = new SPSocialActorInfo();

                Uri serverUri = new Uri(SPContext.Current.Web.Url);
                Uri relativeUri = new Uri(absouteEncodedPathDocument, UriKind.Absolute);
                newActor.ContentUri = new Uri(serverUri, relativeUri);
                newActor.AccountName = user.LoginName;
                newActor.ActorType = SPSocialActorType.Document;

                if (follow)
                    followManager.Follow(newActor);
                else
                    followManager.StopFollowing(newActor);
            }
        }
        catch (Exception ex)
        {
            retval = ex.Message;
        }
    });

    return retval;
}

Any ideas? What does internal error 11 mean?



Viewing all articles
Browse latest Browse all 25064

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>