I have a webpart in the master page which uses a jscript file to perform microblogging operations. This webpart has similar features like OOB NewsFeed part. There is no problem if I create a post which includes Mention, Url SocialData items, but if the message contains a Hashtag, the following exception is occured.
Microsoft.Office.Server.Social.SPSocialFeedManager.CreatePost: Microsoft.Office.Server.Microfeed.MicrofeedException: InsufficientPermissions : ( Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) ) The current user is not authorized to perform the operation.
I tried the code example which is found in MSDN and got same exception.
// Ensure that the SP.UserProfiles.js file is loaded before the custom code runs.
SP.SOD.executeOrDelayUntilScriptLoaded(PublishPost, 'SP.UserProfiles.js');
// Declare global variables.
var clientContext;
var feedManager;
var resultThread;
function PublishPost() {
// Initialize the current client context and the SocialFeedManager instance.
clientContext = SP.ClientContext.get_current();
feedManager = new SP.Social.SocialFeedManager(clientContext);
var socialDataItem = new SP.Social.SocialDataItem();
socialDataItem.set_itemType(SP.Social.SocialDataItemType.tag);
socialDataItem.set_text('#hashTag');
var socialDataItems = [ socialDataItem ];
// Create the post content.
var postCreationData = new SP.Social.SocialPostCreationData();
postCreationData.set_contentText('The text for the post, which contains a {0}.');
postCreationData.set_contentItems(socialDataItems);
// Publish the post. Pass null for the "targetId" parameter because this is a root post.
feedManager.createPost(null, postCreationData);
clientContext.executeQueryAsync(PostSucceeded, PostFailed);
}
function PostSucceeded(sender, args) {
$get("spanMessage").innerText = 'The post and reply were published.';
}
function PostFailed(sender, args) {
$get("spanMessage").innerText = 'Request failed: ' + args.get_message();
}
It works if I use this code in "MySite" collection.
What should I configure to send messages including hashtags in other site collections?