How to use the HTTP API For Supabase to GET / POST data and return records?
I am struggling to use the Supabase http api, and looking for some more detailed documentation — for example, the required headers for different types of requests. (It took me a long time of searching to realize that a 'PREFER' header is required to try and return a record while inserting, is there any official documentation for requirements like that?
As an example, in a Netlify function, I am trying to make a POST request work. When the function is structured like this:
It successfully creates a new record in the specified table, but returns an invalid response.
When I try this function instead, using the Prefer header
I get the following error, which doesn't appear when making the same http request just without the 'Prefer' header.
Can someone help me with some more detailed and simple code examples for the http api, such as
inserting a record and returning the result
, getting records from a table
, getting records with a filter
, and getting records with a foreign key reference included
?2 Replies
This is the REST API. https://postgrest.org/en/stable/references/api.html
PostgREST
API
PostgREST exposes three database objects of a schema as resources: tables, views and stored procedures. Tables and Views, Stored Procedures, Schemas, Computed Fields, Domain Representations, Pagination and Count, Resource Embedding, Resource Representation, Media Type Handlers, Aggregate Function...
I had totally missed that, thank you so much @garyaustin, I should have taken a closer look. Really appreciate it, and hope you're doing well and having a nice end of year. thank you again.