Making OData call using Refit

-- -- 952 Reputation points
2022-02-02T01:55:38.237+00:00

I have an OData query as below.

http://localhost:65202/api/odata/StaffBookings?$select=ID&$filter=Staff/ID eq 1&$expand=Staff($select=ID),Event($select=ID,EventDate;$expand=Client($select=ID,Company))

How can I call it using Refit?

Thanks

Regards

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
41,546 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Gargavar 1 Reputation point
    2022-05-31T12:57:13.763+00:00

    Refit is recommended by Microsoft (I forget the actual link), so that's not a really helpful MSFT answer IMHO.

    Anyway, I found this answer for OData: https://stackoverflow.com/questions/70947350/making-odata-call-using-refit

    0 comments No comments

  2. Manas Padhi 0 Reputation points
    2025-01-16T18:52:34.88+00:00

    Adding the System.Text.Json.Serialization.JsonPropertyName attribute with the $string to the class property which needs the ODataQueryParms works as well.

    public class ODataQueryParms

    {

    [JsonPropertyName("$select")]

    public string? SelectColumns {get; set;}

    //Similar for other fields like filter, top and skip

    }

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.