Can I perform an HTTP GET on /rpc/method(jsonb)? #3874
-
From the documentation we have the ability to do an HTTP POST to an RPC method with a single unnamed json or jsonb parameter, but this option doesn't seem to work with HTTP GET. I have not yet tried with setting the Any ideas on how to (or if I can) make this work? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
How would a function with an unnamed parameter work through GET? You have no query param to use, it doesn't seem to make much sense for GET. What's your use case? Why you cannot use POST? |
Beta Was this translation helpful? Give feedback.
-
Failing to find a function with a matching set of parameters, if a matching function name with a single unnamed json/jsonb parameter exists, wrap all of the URL query parameters into an appropriate object and make the call. I do have query parameters, but I could have a variable number of them. Interestingly enough, the spec allows for multiple query parameters of the same name, which probably means folding them into an array. I could live without that, though :-) My particular use case deals with HTML forms, where a GET retrieves the form contents and a POST updates the DB based on the form data. Currently I work around it by creating a separate function of the same name with just the parameter(s) required to identify the data to edit and use that to NOTE: Despite a long career, I have almost no PostgreSQL (or SQL in general) experience. Feel free to tell me "Don't do it like that because..." :-) |
Beta Was this translation helpful? Give feedback.
Do you still know them in advance, just not which of them are part of any given request, or could they be arbitrary?
If you do know them in advance, but they are essentially optional for each request: Create your RPC with all named arguments, but make them
DEFAULT xxx
. When they have a default, they can be omitted.