Skip to content

PostgREST call to function where either an insert or update will be done #3477

Answered by laurenceisla
MyProxyPass asked this question in Q&A
Discussion options

You must be logged in to vote

Hi! Don't know if you checked already, but PostgREST can handle upserts by default with the POST and PUT methods. It does something similar to what your SQL query is doing.

If you still need an RPC (e.g. for more complex queries) then you can use a function. But, in a POST request, the key/values should be sent in JSON format inside the body of the request not as query parameters. So this: ?param_make=honda&param_model=pilot&param_yr=2010&param_msrp=21000 from url="..." should go in json={...} instead. See the Functions section in the docs for more info.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@MyProxyPass
Comment options

Answer selected by wolfgangwalther
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants