I try to follow a page with JavaScript Object Model. My solution is based on many examples in the web and should work...
var siteActorInfo = new SP.Social.SocialActorInfo();
siteActorInfo.set_contentUri(siteInfo.Url);
siteActorInfo.set_accountName(accountName);
siteActorInfo.set_actorType(4);
if (siteInfo.Followed)
followingManager.follow(siteActorInfo);
else
followingManager.stopFollowing(siteActorInfo);
clientContext.executeQueryAsync(function () {
if (onSuccess) onSuccess();
}, function (a,error) {
if (onError) onError(error.get_message());
});
But when I try to follow or unfollow the page, I get this error:
Specified argument was out of the range of valid values. Parameter name: actor.ActorType
The SP.Social.SocialFollowingManager
is initialized in another function and generally works.
It was not a problem to retrieve the list of followed sites.
I don't understand, whats the problem here.
Instead of 4 I also tried SP.Social.SocialActorTypes.sites
, but this makes, no difference of course, because the value of the property is 4.