Error when using orderby

Rizwan Ansari 91 Reputation points
2023-09-04T07:43:20.7733333+00:00

Dear Experts,

I am calling sharepoint rest api using graph,

https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items?expand=fields(select=Title)&$orderby=fields/SortOrder

Added the column to index also added

'Prefer: HonorNonIndexedQueriesWarningMayFailRandomly'

in header.

but getting error in response:

{
    "error": {
        "code": "invalidRequest",
        "message": "Field 'SortOrder' cannot be referenced in filter or orderby as it is not indexed. Provide the 'Prefer: HonorNonIndexedQueriesWarningMayFailRandomly' header to allow this, but be warned that such queries may fail on large lists.",
        "innerError": {
            "date": "2023-09-04T07:34:20",
            "request-id": "32b25e8a-38c8-45b4-a377-f95c39e0dd87",
            "client-request-id": "32b25e8a-38c8-45b4-a377-f95c39e0dd87"
        }
    }
}

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
2,088 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
8,072 questions
{count} votes

Accepted answer
  1. RaytheonXie_MSFT 24,201 Reputation points Microsoft Vendor
    2023-09-04T09:01:30.37+00:00

    Hi @Rizwan Ansari @Iginio Colangelo,

    Per your descriptions, there might be some issues in the backend of Graph api. As a workaround, I will suggest you to raise a support in Microsoft Azure. You can report this bug to Microsoft and get a response within one business day usually.

    1 person found this answer helpful.

4 additional answers

Sort by: Most helpful
  1. Garcia Argüez, Javier 15 Reputation points
    2023-09-04T08:30:15.3166667+00:00

    I have the same problem, the app has stop working this weekend. I have tried in MS Graph with different lists and documents libraries and have the same error. And the fields are indexed a long time ago.

    1 person found this answer helpful.

  2. Bayraktar, Aytac 5 Reputation points
    2023-09-05T13:48:24.9066667+00:00

    User's image

    1 person found this answer helpful.
    0 comments No comments

  3. RaytheonXie_MSFT 24,201 Reputation points Microsoft Vendor
    2023-09-04T08:38:19.51+00:00

    Hi @Rizwan Ansari,

    Per my test, query parameter $orderby can be applied on the expanded properties of fieldvalueset, and usage of the is not recommended large lists. Please refer to following

    https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items?$expand=fields&$orderby=fields/SortOrder desc 
    Prefer: HonorNonIndexedQueriesWarningMayFailRandomly
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  4. Chetan Kolhari 0 Reputation points
    2023-09-05T05:42:27.2866667+00:00

    I have customer complains about having the same issue in their tenants from yesterday. So far any progress from Microsoft anyone heard?