Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Below is the issue i am getting while try to like any SPSocial Feed.

"Microsoft.Office.Server.Microfeed.MicrofeedException. Internal error code: 28".

My Code is Working perfect in Console application but in webpart is't not :(

Please look into sample code to get detail about the issue.

const string siteUrl = "http://server/sites/sitename";
            const string user = "domain\\username";

            using (SPSite site = new SPSite(siteUrl))
            {
                SPUser userContext = site.RootWeb.SiteUsers[user];
                SPUserToken userToken = userContext.UserToken;

                SPServiceContext serviceContext = SPServiceContext.GetContext(site);

                using (new SPServiceContextScope(serviceContext))
                {

                    UserProfileManager profileManager = new UserProfileManager(serviceContext);

                    UserProfile userProfile = profileManager.GetUserProfile(userContext.LoginName);

                    SPSocialFeedManager feedManager = new SPSocialFeedManager(userProfile, serviceContext, userToken);

                    SPSocialPostCreationData post = new SPSocialPostCreationData();
                    post.ContentText = "Hi from server object model";

                    feedManager.CreatePost(site.Url+"/newsfeed.aspx", post);

                }
            }


What I have tried:

Already tried with
SPSecurity.RunWithElevatedPrivileges
SPUtility.ValidateFormDigest();
WeB.Allowunsafeupdate
Posted

1 solution

http://answers.flyppdevportal.com/MVC/Post/Thread/68b9fc7e-7e91-4416-a7df-eae48a207460?category=sharepointdevelopment


Quote:
FYI: Today we installed the SharePoint February 2016 CU in our farm. (Build: 15.0.4797.1000)

And we can confirm that this is finally working again.
 
Share this answer
 
Comments
Member 11093838 7-Mar-17 2:16am    
I got the solution the only thing we need to do this-

HttpContext httpCtx = HttpContext.Current;
HttpContext.Current = null;

:)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900