0

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

Alex
  • 12,078
  • 6
  • 64
  • 74

2 Answers2

1

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.

Jodok Batlogg
  • 373
  • 1
  • 9
  • Thanks for the advice. I'll have to ask the person who created the database I think. – Alex Jan 07 '17 at 00:19
  • You are correct. Turns out it's a Reverse Proxy using NGINX with HTTP Basic Authentication. – Alex Jan 09 '17 at 18:09
1

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"}'

Alex
  • 12,078
  • 6
  • 64
  • 74