linqmicrosoft-graph-apisharepoint-list

Correct syntax of OrderBy in GraphClient request


Given the following GraphClient request (query some ListItems from a SharePoint List)

   var currentId = await MyGraphClient.graph.Sites[xxxxxxxxxxxxxxx]
        .Lists[xxxxxxxxxxxxxxxxxx]
        .Items
        .Request()
        .OrderBy("TicketID")
        .GetAsync();

This is giving me a bad request error, saying that it doesn't recognize the property TicketID. I know that it's the correct name of the column since I'm using it somewhere else in my application (expanding the fields).

What would be the correct syntax to order my request result (descending)?

Thank you everyone!


Solution

  • Try to order by fields/TicketID

    var currentId = await MyGraphClient.graph.Sites[xxxxxxxxxxxxxxx]
            .Lists[xxxxxxxxxxxxxxxxxx]
            .Items
            .Request()
            .OrderBy("fields/TicketID")
            .GetAsync();