-
Notifications
You must be signed in to change notification settings - Fork 163
GET call with in
filter to POST call (414 URI too long)
#417
Comments
Hey @Pavan-anonymous, Can you share the request you're doing? Does it have a lot of filters or an |
@steve-chavez Thanks for the response. I cant share the request but yes it has only two 'in' filters and one among them has values ranging from any where between 1 - 3000 (and each value about 20 characters). Can you suggest on this |
@Pavan-anonymous I see. In that case you could convert the GET to POST with a function. It should be like: create or replace function projects_in(vals int[]) returns setof projects as $$
select * from projects
where id = any(vals);
$$ language sql; POST /rpc/projects_in # you can add any of the GET filters to POST "?id=eq.2&select=id,name,clients(*)"
{"vals": [1,2,3,4,5,6,7,8,9,10,....]} # any size of IN values here |
Thanks @steve-chavez |
@steve-chavez I'm confused with the above suggestion. Below is the sample request which will work but if the locations gets increased (if we add more states with many counties) it gives bad request message. Please suggest how we can convert this GET call to POST or any other way we can make it work. |
@Pavan-anonymous It should be like this: create or replace function sales_locations_in(vals text[]) returns setof sales as $$
select * from sales
where locations = any(vals);
$$ language sql; Then you can use POST for the locations: POST /rpc/sales_locations_in?practice=in.(practice_type)
{"vals": ["florida/Falachua", "florida/baker", "etc"]} |
The upcoming HTTP QUERY method could help us with this issue. |
in
filter to POST call
in
filter to POST callin
filter to POST call (414 URI too long)
We currently make a GET call thats works fine with small query, but the issue is when the query is too long its not able to handle. So i want to change it to a POST call on my code side but i am not sure how it works in PostgREST, can someone help me with how to do that. Thanks for your help in advance.
The text was updated successfully, but these errors were encountered: