i would like to rate items via rest API. and i would like get user specific ratings. so if the user rated an item with 5 stars i want to see 5 stars somewhere in XML from rest API. By default i receive a XML including RatingCount and AverageRating. (if there is at least one Rating) But how to get my own rating to display in a UI And how to rate if there is no Value to change? I searched for hours, but can t find any real hint. is there even a way to do this via rest? I am using C#.
1 Answer
Here is JSOM solution for your reference(get rated users and the score):
<script type="text/javascript">
SP.SOD.executeOrDelayUntilScriptLoaded(CustomJS, 'sp.js');
function CustomJS() {
var ctx = SP.ClientContext.get_current();
var web = ctx.get_web();
var list = web.get_lists().getByTitle("Documents");
var item = list.getItemById(1);
ctx.load(item);
ctx.executeQueryAsync(function (sender, args) {
var _RatedBy = item.get_item('RatedBy');
var _Ratings=item.get_item('Ratings')
})
}
</script>
For rating, you cold check the similar thread below.