-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to add a Custom Header to a Request and Retrieve Response Header Value #99
Comments
Could you elaborate what you want to achieve with these headers? Both the use case for sending along custom headers, and picking up response headers? |
When we send a request with the following header:
Supabase returns the total count of records in the response header like this:
This allows us to get the total number of records without making a second API call, which is useful for implementing pagination in the UI with just a single request. I'd like to be able to set the Prefer header to count=exact in my request and read the Content-Range header from the response. This would optimize the API usage for pagination purposes. |
That makes sense, the first step could be to either just flat out provide full access over headers when requesting and getting the reponse, or wrap them nicely in various objects and setters, to avoid handling the API spec behind. But I definitely see your use-case, seems like it just comes down to not supporting the full API yet. |
Actually that is not entirely true, I can see the (QueryOptions)[https://github.com/supabase-community/postgrest-csharp/blob/master/Postgrest/QueryOptions.cs] class handles these attributes. It looks like it comes down to not being able to pass these on Select request, but only update, delete, insert and upsert. |
Has there been any movement on this since October? I'm running into this issue myself - I'm trying to do a lot of filters on my DB in my API and get both the results and the count for pagination, and as far as I can tell there's no simple way to do so? I've made my own fork solely to fix this issue for myself and am now using my local version, but I've put a PR out with the additions I made in case they're useful to anyone else. |
Feature request
Is your feature request related to a problem? Please describe.
I'm currently working on a project using Supabase in C#, and I need to add a custom header to my requests. Additionally, I want to retrieve a specific header value from the response.
I've been able to make basic requests, but I'm not sure how to modify the request to include a custom header or how to access the headers from the response. Could anyone provide an example or guidance on how to achieve this in C#?
Describe the solution you'd like
I thinking like this
query.GetHeaders().TryAdd("prefer", "count=exact");
Describe alternatives you've considered
Additional context
The text was updated successfully, but these errors were encountered: