You could consider the following options
Option 1.
1) modify the query to include additional information. Since Ratings properties belong to ListItem resource, append the following expression: $expand=ListItemAllFields to the endpoint url
2) once the data is returned perform the filtering by on the client side by Ratings field
Example:
var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/getfolderbyserverrelativeurl('/sites/contoso/documents')/files?$expand=ListItemAllFields"; $.getJSON(url) .then(function(data){ var result = data.value.filter(function(item){ if(item.ListItemAllFields.LikedByStringId.indexOf(_spPageContextInfo.userId.toString()) >= 0) return item; }); console.log(result.length); });
Option 2.
Replace the endpoint /_api/web/GetFolderByServerRelativeUrl('<url>')/files with GetItems method:
Url:/_api/web/Lists/GetByTitle('<listTitle>')/GetItems?$expand=File Method: POST Data: { "query": { "__metadata": { "type": "SP.CamlQuery" }, "ViewXml": "<View><Query><Where><Eq><FieldRef Name=\"LikedBy\" LookupId=\"TRUE\"/><Value Type=\"UserMulti\">17</Value></Eq></Where></Query></View>", "FolderServerRelativeUrl": "/sites/contoso/Documents/Archive" } } Headers: X-RequestDigest: <request digest> Accept: "application/json; odata=verbose" Content-Type : "application/json; odata=verbose"
Advantages:
Example
var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/Lists/GetByTitle('Documents')/GetItems?$expand=File"; var query = "<View>" + "<Query>" + "<Where>" + "<Eq>" + "<FieldRef Name=\"LikedBy\" LookupId=\"TRUE\"/>" + "<Value Type=\"UserMulti\">" + _spPageContextInfo.userId + "</Value>" + "</Eq>" + "</Where>" + "</Query>" + "</View>"; var folderUrl = _spPageContextInfo.webServerRelativeUrl + "/Documents/Archive"; var queryPayload = { "query" : { "__metadata": { "type": "SP.CamlQuery" }, "ViewXml": query, "FolderServerRelativeUrl": folderUrl } }; executePost(url,queryPayload) .then(function(data){ var items = data.d.results; items.forEach(function(item){ //console.log(item.LikesCount); //Likes count //console.log(item.LikedByStringId); //user ids console.log(item.File.Name); //File properties like Name }); })
where
function executePost(url,payload){ return $.ajax({ url: url, method: "POST", data: JSON.stringify(queryPayload), headers: { "X-RequestDigest": $("#__REQUESTDIGEST").val(), "Accept": "application/json; odata=verbose", "Content-Type": "application/json; odata=verbose" } }); }