Crate SQL query using curl with basic access authentication

6.5k views Asked by At

From the crate.io documentation I am told that an SQL query can be performed like this:

curl -sSXPOST 'CLUSTER_IP:4200/_sql?pretty' -d '{"stmt":"select name from sys.cluster"}'

The database I am trying to connect to requires a username and password:

Auth

How can I build this authentication into the curl call? I have tried several variants of things I found online with no success. The error I keep seeing looks like this:

enter image description here

2

There are 2 answers

2
Jodok Batlogg On

Out of the box CrateDB does not provide any authentication. Maybe you are running a HTTP Proxy or loadbalancer with authentication in front of it? NGINX? Try to connect to one of the CrateDB servers instead.

0
Alex On

The query worked when I included the login credentials as follows:

curl -sSXPOST 'username:password@hostname:port/_sql?pretty' -d '{"stmt":"select name from sys.cluster"}'