I am trying to get the current logged in user rating for items in document libraries . However. It is giving rating as 0 for the all the documents. I am using below code
SPSite site = new SPSite(SPContext.Current.Web.Url);
{
SPWeb web = site.OpenWeb();
{
string fileUri = "http://..." + webUrlSplit;
Uri urifileUrl = new Uri(fileUri);
SPServiceContext context = SPServiceContext.GetContext(site);
SocialRatingManager mySocialRatingManager = new SocialRatingManager(context);
SocialRating aRating = mySocialRatingManager.GetRating(urifileUrl);
string myRating = aRating.Url + ": " + aRating.Rating;
objtopRated.myRating = myRating;
}
}
In the above code fileUri is the docuemnt url of the item in doc library
eg. someSiteUrl/ProductsandPricing/Pricing/Pricing_Document 1.xlsx
I referred the below msdn link