I have a list which is to be sorted accoring to the average rating column and the top 3 items is to be displayed in react js.

This is the api endpoint used :


How to sort the result according to the average rating column to get the 3 top rated items ?


1 Answer 1


The average rating of a column is stored in a list column whose internal name is AverageRating. However, to sort on that column we need to make a POST request with a CAML query as it can't be ordered by in a normal HTTP GET request.

Make the changes from the below sample code in your spHttpClient's methods :

const options: ISPHttpClientOptions = {
    headers: {'odata-version':'3.0'},
    body: `{'query': {
      '__metadata': {'type': 'SP.CamlQuery'},
      'ViewXml': '<View>
                      <OrderBy><FieldRef Name="AverageRating"" Ascending=""False"" /></OrderBy>

var endPoint = `${this.props.siteurl}/_api/web/lists/GetByTitle('Site Pages')/GetItems`;

    .then((response: SPHttpClientResponse) => {
      return response.json();
  • hey @swetanayak, hope this answers your question. Please mark it as answer if it helped your query, its just a checkmark besides the answer ! It will remove this from the unanswered section as well. Thanks ! Commented Jul 5, 2018 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.