connecting to local elastic search which is password protected is giving 405 response code
I am using v. 2.9.24 from the cdn
"dataSource": {
type: "api",
url: "https://localhost:9200",
index: "sample-cud-data",
requestHeaders: {
'Authorization': "user xxxxxxx"
},
Summary
URL: https://localhost:9200/handshake
Status: 405 Method Not Allowed
Source: Network
Address: ::1:9200
Request
POST /handshake HTTP/1.1
Accept: */*
Origin: http://localhost:8010
Content-Type: application/json
Authorization: elastic 7LKKSd4qhtOA1S+ECPxh
Referer: http://localhost:8010/
Content-Length: 39
Host: localhost:9200
Accept-Language: en-IN,en-GB;q=0.9,en;q=0.8
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Response
HTTP/1.1 405 Method Not Allowed
Access-Control-Allow-Credentials: true
Content-Type: application/json
Vary: origin
Content-Length: 120
Access-Control-Allow-Origin: http://localhost:8010
Allow: DELETE,GET,HEAD,PUT
X-elastic-product: Elasticsearch
Hello, Kiran!
Thank you for contacting us.
We want to inform you that Flexmonster has a special syntax for connecting to ElasticSearch datasource.
Please, try the following code sample:
dataSource: {
type: "elasticsearch",
node: "https://localhost:9200",
index: “sample-cud-data”,
}
You can find more information about Elastic datasource in our docs: https://www.flexmonster.com/doc/connecting-to-elasticsearch/.
Please note that ElasticSearch has its authorization rules, so we should configure the request headers as follows:
requestHeaders: {
Authorization: Basic <TOKEN>
}
The <TOKEN> is computed as base64(USERNAME:PASSWORD)
For more details, please refer to the Elastic securing guide: https://www.elastic.co/guide/en/elasticsearch/reference/current/http-clients.html.
We hope it helps. Feel free to contact us if any further questions arise.
Regards,
Solomiia
after changing to elasticsearch and from url to node it is working
Hello again!
Thank you for your quick response.
We are glad to hear that our suggestion works for you.
You are welcome to contact us if any further questions arise.
Best regards,
Solomiia