I'm using postgrest
as an API wrapper to my postgres
db. The api reads my database schema and creates URL using common characters in the address.
I have a function like so = create function api.dividend(p_stocks text[])
A general API call:
/url?key=val;key2=val2
My API call for function create function api.dividend(p_stocks text[])
:
/dividend?p_stocks=AAPL
In this case to test things out, I used AAPL
as the input parameter.
However this is the error I'm getting:
function api.dividend(p_stock => text) does not exist
As you see the return error is expecting this function, api.dividend(p_stock => text)
However I tried creating a function using those parameters and I dont think its possible...
I would greatly appreciate some advice or suggestions on what suggestions I should try?
This isn't a schema problem because I've checked if the function is in the appropriate schema.
Here is the full function from postgres, if this helps:
create function dividend(p_stocks text[])
returns table(symbol char, next_dividend_date date, ex_dividend_date date)
as $$
select distinct on (symbol) symbol, next_dividend_date, ex_dividend_date
from api.security_stats
where api.security_stats.symbol = any($1)
order by symbol, date desc
$$ language sql;
I managed to solve the issue with the help of @Adrian,
/dividend?p_stocks=%7BAAPL%7D
This would be the correct URL path for postgrest to use the function/parameter.
%7b
={
, and%7D
=}
Now the URL has the correct array format for my function.