FlutterFlow / flutterflow-issues

A community issue tracker for FlutterFlow.
98 stars 17 forks source link

HEAD method not supported in API calls #2840

Closed VinceT closed 2 weeks ago

VinceT commented 2 weeks ago

Has your issue been reported?

Current Behavior

Hi, I use PostgREST. I tested the "GET" method which works fine. But I want to count records and the only way is to use "HEAD" (https://postgrest.org/en/v12/references/api/pagination_count.html#exact-count). It works on other projects I have (PHP, Capacitor). It seems that only GET, POST, DELETE, PUT and PATCH are available.

Expected Behavior

Is there a work-around to count records ?

Steps to Reproduce

Create a new API call

Reproducible from Blank

Bug Report Code (Required)

IT4wi8mAw49grs9e+KryccFsimEvIjs3aq801upubCs9GYjyO5YUac6lV1hWXdekSmw+KEWGjnoG0sr7uN/QV/AnGyuubr5Dys1ASg/vcEW/aoS6DbWOfHFTP+BmJkOP0ZiVuglQHNpecXAW1F+PeuvKEnLsN4P7Zwh9f6PHaOI=

Context

Impossible to get a count.

Visual documentation

image

Additional Info

No response

Environment

- FlutterFlow version: FlutterFlow v4.1.45+ released April 26, 2024
Flutter version is 3.19.1
- Platform:
- Browser name and version:Chrome Version 124.0.6367.92 (Build officiel) (64 bits)
- Operating system and version affected: Windows 10 Version 22H2

General

Relative to the time the changes were made, data was lost within

When following my steps to reproduce, data loss happens

rzambroni commented 2 weeks ago

Hey @VinceT, as you said there is currently no support for HEAD calls.

I don't have any context of your backend, but you should be able perform a count by using the SQL query itself and retrieve it on a GET request.

Something like:

SELECT COUNT(*) AS user_count FROM users;

Hope that helps!

I will add a feature request for the head calls, however, i don't think they will be a priority for the team in the short term.

Thanks!

VinceT commented 2 weeks ago

Unfortunately, it's not possible in PostgREST to do so. Based on "http://my_site/my_table?select=field1,field2" "http://my_site/my_table?select=count%28*%29" is not allowed and generates a PGRST100 Error.

rzambroni commented 2 weeks ago

@VinceT, I found this on the docs: https://postgrest.org/en/v12/references/api/aggregate_functions.html#the-case-of-count
It could probably help you, but I'm not an expert on the matter.

I'm closing this ticket as it was added to our internal backlog as a feature request and we will be tracking it there.

Thanks!

VinceT commented 2 weeks ago

Hi, Nice ! Thanks for this. It works in the opposite way that the doc indicates. That is : no parenthesis gives the result and () gives a PGRST123 error message. Anyway, it's useful.

Le mar. 30 avr. 2024 à 03:41, rzambroni @.***> a écrit :

@VinceT https://github.com/VinceT, I found this on the docs: https://postgrest.org/en/v12/references/api/aggregate_functions.html#the-case-of-count It could probably help you, but I'm not an expert on the matter.

I'm closing this ticket as it was added to our internal backlog as a feature request and we will be tracking it there.

Thanks!

— Reply to this email directly, view it on GitHub https://github.com/FlutterFlow/flutterflow-issues/issues/2840#issuecomment-2084109467, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADGHWUZHB6QX5YPVXNJBQDY73ZC7AVCNFSM6AAAAABG7CTRN2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBUGEYDSNBWG4 . You are receiving this because you were mentioned.Message ID: @.***>

rzambroni commented 2 weeks ago

Great, i'm glad it worked!

Have a great week.