SharePoint 2013 – Enable Ratings on a list programatically via the REST API

I have searched a lot and been through much trial and error trying to get this to work. So I thought it might benefit someone if I share it.

For this article it is assumed that you are used to working with the SharePoint REST API. If not, MSDN has a lot of great articles with examples on this. Make sure to also include the X-RequestDigest  header when sending POSTs to SharePoint (Google “SharePoint X-RequestDigest REST POST” for more info – or let me know if this needs elaboration :)).

1 Create a list

Use the REST API or whatever method you prefer. See the Create a list example at MSDN for an example on how to do it via the REST API.

2 Create the needed fields

In order to specify the field IDs and FieldRefs while creating the fields via REST, we are going to be using the createfieldasxml method located at http://<site url>/_api/web/lists/GetByTitle('LISTTITLE')/fields/createfieldasxml . We need to POST the following data in order to create a field. I have included the needed XML for each field in the Field list below. Do 1 post for each field changing the XML FROM THE FIELD LIST BELOW to the XML for the field.

Field list

3 Set the Ratings_VotingExperience property on the list

This is done by posting the following data to  http://<site url>/_vti_bin/client.svc/ProcessQuery . Change the LISTTITLE to the title of your list.

And you are done. The list now has Likes enabled.

This article was written in a short amount of time and therefore, is not very elaborate. Please let me know if it needs more examples or further explanations.

Happy coding 🙂

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *