drobin
drobin

Reputation: 276

curl syntax for PostgREST query

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?

Upvotes: 2

Views: 5114

Answers (1)

Steve Chavez
Steve Chavez

Reputation: 1176

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).

Upvotes: 4

Related Questions