I am not sure why this function is not being found upon request #2417
-
So, I was trying to make a kind of complex PL/pgSQL function accessible via postgREST but kept failing and got always the error: {
"hint": null,
"details": null,
"code": "42P01",
"message": "relation \"api.globalquery\" does not exist"
} However, my function does of course exists, as proven by curling /rpc/ "/rpc/globalquery": {
"post": {
"tags": [
"(rpc) globalquery"
],
"produces": [
"application/json",
"application/vnd.pgrst.object+json"
],
"parameters": [
{
"required": true,
"schema": {
"required": [
"_tables",
"_filter"
],
"type": "object",
"properties": {
"_filter": {
"format": "json"
},
"_tables": {
"format": "json"
}
}
},
"in": "body",
"name": "args"
},
{
"$ref": "#/parameters/preferParams"
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
} I then tried with an example from the postgREST documentation. So I created the function CREATE FUNCTION api.pplus(x integer, y integer)
RETURNS integer AS $$
SELECT x + y;
$$ LANGUAGE SQL IMMUTABLE; made it available to remote_user and then curled with curl "https://localhost:3000/rpc/pplus" -X POST -H "Content-Type: application/json" -d '{ "x": 1, "y": 2 }' and I keep getting the same error, although pplus also appears in the /rpc/ curl. Anyone knows what I am doing wrong? I would be greatly appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
How did you call the |
Beta Was this translation helpful? Give feedback.
-
The error you get is as if it's selecting from a non existent table from the database, like: Also, which version of PostgREST and PostgreSQL are you running? |
Beta Was this translation helpful? Give feedback.
The error you get is as if it's selecting from a non existent table from the database, like:
curl "http://localhost:3000/globalquery"
. When the function is not found the error is different. I noticed that you're usinghttps
which is not supported out of the box; perhaps a web server like Nginx is changing something there?.Also, which version of PostgREST and PostgreSQL are you running?