2

Using PostgREST (http://postgrest.org/en/v5.2/api.html) version 5.2 against a Postgres 11 database, the following curl command:

curl -X GET http://192.18.11.13:5741/workorder?acctid=eq.SunnySide&workorderid=eq.0001

generates the following trace in the Postgres log:

SELECT "public"."workorder".* FROM "public"."workorder"  WHERE  "public"."workorder"."acctid" = 'SunnySide'::unknown

The "restriction" of workorderid=eq.0001 in the original query is dropped so the data returned includes all 'SunnySide' matches and not the single 0001 workorderid as desired.

What is the correct syntax of this command in curl so that workorderid is also passed to the Postgres server?

drobin
  • 286
  • 2
  • 6

1 Answers1

4

You need to quote("") the url. Like:

curl "http://192.18.11.13:5741/workorderacctid=eq.SunnySide&workorderid=eq.0001"

Otherwise your shell will treat the command after the & symbol as a background process. That's why workorderid=eq.0001 doesn't get included in the curl call. It's actually being interpreted as a separate command(variable assignment).

Steve Chavez
  • 931
  • 10
  • 13
  • 1
    I would even recommend single quotes to ensure the shell interprets nothing at all. See https://stackoverflow.com/questions/6697753/difference-between-single-and-double-quotes-in-bash – Tom Jan 22 '23 at 02:41