Update Average Rating type field

How to update an Average Rating type of field from Star Rating to Likes in a SharePoint Online list using a Power Automate flow.

URI

_api/Microsoft.SharePoint.Portal.RatingSettings.SetListRating(listID=@a1,ratingType=@a2)?@a1=@{encodeUriComponent(variables('ListId'))}&@a2=2

Headers

{
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose"
}

Body

Not applicable

Screenshot with example

Sample data
ListId – ‘3e63a642-59fe-4419-8dad-375ac0a3f006’ (Don’t forget the single quotes. The value also needs to be encoded, the encodeUriComponent function is used for that)
ratingType – 2 (Star Ratings is 1, Likes is 2)

updateaverageratingfield

Expected response

HTTP statusCode with 200 with a SetListRating null value returned.

{
"d": {
"SetListRating": null
}
}

Copy/paste example

{"id":"14cc7ad1-3514-4a4e-8702-4b8bbf1a505e","brandColor":"#036C70","connectionReferences":{"shared_sharepointonline":{"connection":{"id":"/exp_sharedsharepointonline_e5efa"}}},"connectorDisplayName":"SharePoint","icon":"https://connectoricons-prod.azureedge.net/releases/v1.0.1685/1.0.1685.3700/sharepointonline/icon.png","isTrigger":false,"operationName":"Send_an_HTTP_request_to_SharePoint","operationDefinition":{"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_sharepointonline","operationId":"HttpRequest","apiId":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline"},"parameters":{"dataset":"@parameters('SPOSiteCollection_PowerUsers (exp_SPOSiteCollection_PowerUsers)')","parameters/method":"POST","parameters/uri":"_api/Microsoft.SharePoint.Portal.RatingSettings.SetListRating(listID=@a1,ratingType=@a2)?@a1=@{encodeUriComponent(variables('ListId'))}&@a2=2","parameters/headers":{"Accept":"application/json;odata=verbose","Content-Type":"application/json;odata=verbose"}},"authentication":{"type":"Raw","value":"@json(decodeBase64(triggerOutputs().headers['X-MS-APIM-Tokens']))['$ConnectionKey']"}},"runAfter":{"Initialize_variable_-_ListId":["Succeeded"]},"metadata":{"operationMetadataId":"63923373-05b5-47bc-af21-7bd4eb6b3111"}}}

Expected End result

numberoflikes

Resources

Add a ratings feature to your library

That’s it, Happy testing!

You may also like...

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.