postgrest

PostgRest: fetch by column(id) returns PGRST104 "Failed to parse" error


I was following the tutorial on how to abstract your database using [PostgRest server][1].

[1]: https://postgrest.org/en/stable/tutorials/tut0.html. However when I send the following command to Postgrest's web server. To return rows where id = 1

curl -X 'GET' \
  'http://127.0.0.1:3000/todos?id=1' \
  -H 'accept: application/json' \
  -H 'Range-Unit: items'

I'll get the following response

{
  "code": "PGRST104",
  "details": "Failed to parse [(\"id\",\"0\")]",
  "hint": null,
  "message": "Unexpected param or filter missing operator"
}

The following are the environment variables that summarize my PostgRest webserver configuration don't worry it's not in production.

PGRST_DB_URI=postgres://authenticator:mysecretpassword@db:5432/postgres
PGRST_OPENAPI_SERVER_PROXY_URI=http://127.0.0.1:3000
PGRST_DB_ANON_ROLE=web_anon
PGRST_DB_SCHEMAS=api
PGRST_OPENAPI_MODE=follow-privileges
PGRST_JWT_SECRET=L3J5dptOFFF4OSRAAAAA44556TnKKKIxBZEEEJio9

Solution

  • As the error suggests, an operator is missing (more precisely, an equality operator according to your example). So, to get the todo where id = 1 the URL should be:

    http://127.0.0.1:3000/todos?id=eq.1