Skip to content
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

Open
bhagavan44 opened this issue Aug 23, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@bhagavan44
Copy link

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

@bhagavan44 bhagavan44 added the enhancement New feature or request label Aug 23, 2024
@MagnusHJensen
Copy link

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?

@bhagavan44
Copy link
Author

When we send a request with the following header:

Prefer: count=exact

image

Supabase returns the total count of records in the response header like this:

Content-Range: 0-9/50

image

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.

@MagnusHJensen
Copy link

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.

@MagnusHJensen
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants