0
votes

I'm trying to create a Sharepoint iOS app and using the rest api I get the error "Likes are not supported in this item." after doing a POST to https://tenant.sharepoint.com/News/_api/web/lists/getbytitle('pages')/items('1234')/like.

Anyone knows more about this kind of error?

The Rating settings seems to be set correctly on the Sharepoint server, because the like option works correctly on the website, and also in the app I can see the likesCount properties on the response for the Rest API call https://tenant.sharepoint.com/News/_api/web/lists/getbytitle('pages')/items('1234').

I don't think there is something wrong with the client app implementation, but it is something related to the Sharepoint configuration, although I haven't seen any more settings in regards to the Rating settings including the Sharepoint access for the mobile app.

The web seems to handle this using the Microsoft.Office.Server.ReputationModel.Reputation.setLike function which again works correctly on the web parts, but I couldn't find a way to do it from the mobile app.

1

1 Answers

0
votes

To set Likes for the list item, we need use the API below with POST request.

https://tenant.sharepoint.com/News/_api/web/lists/getbytitle('pages')/items('1234')

And pass the data of the POST request as below.

var item = {
    "__metadata": { "type": "SP.Data.PagesItem"},
    "LikedByStringId":  {"results": ["11"]},
    "LikesCount": 2
};

Before set Likes for the item, we need get the "LikedByStringId" and "LikesCount" value of the list item using API below with GET request, then set the new one.

https://tenant.sharepoint.com/News/_api/web/lists/getbytitle('pages')/items('1234')

Check the article here: Demonstrates how to like/unlike resource via SharePoint REST API