Getting the confusing SharePoint 2013 SocialDataStoreException
Ran into a bit of a problem figuring out an exception I received while writing a SharePoint 2013 apps.
As I was writing an app using the new SharePoint 2013 app model the other day, I ran into an issue when I was trying to follow a site automatically through JavaScript:
The problem seemed fairly straight-forward. The targeted site I wanted to follow couldn’t be found. However, it didn’t make sense. The instance URL I was targeting (https://chrisweldon.sharepoint.com) did in fact exist. Furthermore, I was not already following that site. So, why was this failing?
Let’s take a look at some code:
This is fairly straight-forward. I simply setup a social actor to follow and call out to the SocialFollowingManager
to attempt to follow that site. This is when I thought, perhaps this is a permissions problem? I’m trying to have the JavaScript object model write a request to the Social datastore. Perhaps it wasn’t authorized.
I changed the permissions in my AppManifest.xml
from Read to Write:
Scope | Permission |
---|---|
User Profiles (Social) | Write |
Sadly, I received the same error message. However, if you read the MSDN Documentation on Developing Social Features in SharePoint 2013, there is a section in there talking about user profiles:
User Profiles (http://sharepoint/social/tenant) The permission request scope used to access all user profiles. Only the profile picture can be changed; all other user profile properties are read-only for apps for SharePoint. Apps that request rights for the User Profiles scope must be installed by a tenant administrator.
In a nutshell, I have to grant Tenant permissions to my app to be able to have my user follow a new site. Therefore, my new permissions look like the following:
Scope | Permission |
---|---|
User Profiles (Social) | Read |
Tenant | Write |
As indicated by the paragraph above, the app now needs to be installed by a tenant administrator. However, in doing so, the app now follows sites (and other content) with ease. Why the obscure error message? That I don’t know, and I hope the SharePoint team might look to address this with a more correct error message in the near future.