@accateo
There are 2 URLS for your Elastic Cloud Deployment.
There is the Kibana endpoint
Example... Notice the .kb.
in the url that is used to get to the Kibana app.
https://mycluster.kb.us-west1.gcp.cloud.es.io:9243
If you want to write and read documents directly to elasticsearch you need to use the elasticsearch endpoint
Notice the .es.
https://mycluster123.es.us-west1.gcp.cloud.es.io:9243
So now that we sorted that ... looks like you are originally using the right URL!
I tried yours and you have an extra space after ... 9243/test/_doc "
<-- Right There
Since you put that in a qoutes it is trying to use that trailing space. Also I would clean up the -d
part it really should be -d '{....}'
Does Not Work
curl -v -X POST -u XXX:XXX -H "Content-Type: application/json" "https://XXX.es.europe-west3.gcp.cloud.es.io:9243/test/_doc " -d' { "foo": "bar" }'
Works
curl -v -X POST -u XXX:XXX -H "Content-Type: application/json" "https://XXX.es.europe-west3.gcp.cloud.es.io:9243/test/_doc" -d' { "foo": "bar" }'
If you are getting an error please post the entire error
curl -v -X POST -u elastic:ksjhslkdjfhlskjgfh -H "Content-Type: application/json" "https://mycluster123456.es.us-west1.gcp.cloud.es.io:9243/test/_doc" -d' { "foo": "bar" }'
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 34.83.110.184...
* TCP_NODELAY set
* Connected to mycluster123456.es.us-west1.gcp.cloud.es.io (34.83.110.184) port 9243 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use h2
* Server certificate:
* subject: C=US; ST=California; L=Mountain View; O=Elasticsearch, Inc.; CN=*.gcp.elastic-cloud.com
* start date: Mar 9 00:00:00 2021 GMT
* expire date: Nov 9 23:59:59 2021 GMT
* subjectAltName: host "mycluster123456.es.us-west1.gcp.cloud.es.io" matched cert's "*.es.us-west1.gcp.cloud.es.io"
* issuer: C=US; O=DigiCert Inc; CN=DigiCert TLS RSA SHA256 2020 CA1
* SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Server auth using Basic with user 'elastic'
* Using Stream ID: 1 (easy handle 0x7f83c780f200)
> POST /test/_doc HTTP/2
> Host: mycluster123456.es.us-west1.gcp.cloud.es.io:9243
> Authorization: Basic ZWxhc3RslkjfghsdlfkjghsdflgkjhmTmNaOWFaNlJmbExYZ2k=
> User-Agent: curl/7.64.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 17
>
* We are completely uploaded and fine
* Connection state changed (MAX_CONCURRENT_STREAMS == 250)!
< HTTP/2 201
< content-type: application/json; charset=UTF-8
< location: /test/_doc/3MpDdHgBPpcTMEMZu1ij
< x-cloud-request-id: fNeyQeHaTvG77mK5QxFSIg
< x-found-handling-cluster: 234lkj2134lkj2134klj1234l1kj
< x-found-handling-instance: instance-0000000074
< content-length: 171
< date: Sat, 27 Mar 2021 15:18:19 GMT
<
* Connection #0 to host mycluster123456.es.us-west1.gcp.cloud.es.io left intact
{"_index":"test","_type":"_doc","_id":"3MpDdHgBPpcTMEMZu1ij","_version":1,"result":"created","_shards":{"total":2,"successful":2,"failed":0},"_seq_no":9,"_primary_term":7}* Closing connection 0