1

I am trying to run this command

curl -XPUT -H "Content-Type: application/json" https://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'

But this results in this error

curl: (6) Could not resolve host: http
curl: (3) unmatched close brace/bracket in URL position 5:
null}'

I got this command from here

https://stackoverflow.com/a/50609418/3259896

I'm am not yet very familiar with curl nor elasticseach, so I'm not sure how to pinpoint the error

If it makes a difference, I am using Windows.

I also tried

$ curl -X PUT -H "Content-Type: application/json" https://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'

Edit2:

I tried

curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'

But now get this error

{"error":{"root_cause":[{"type":"json_parse_exception","reason":"Unexpected character (''' (code 39)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@446f2dd5; line: 1, column: 2]"}],"type":"json_parse_exception","reason":"Unexpected character (''' (code 39)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@446f2dd5; line: 1, column: 2]"},"status":400}curl: (3) unmatched close brace/bracket in URL position 5: null}' ^

I then tried

curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d "{"index.blocks.read_only_allow_delete": null}"

And I got

{"error":{"root_cause":[{"type":"json_parse_exception","reason":"Unexpected character ('i' (code 105)): was expecting double-quote to start field name\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@696b36d3; line: 1, column: 3]"}],"type":"json_parse_exception","reason":"Unexpected character ('i' (code 105)): was expecting double-quote to start field name\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@696b36d3; line: 1, column: 3]"},"status":400}

SantoshGupta7
  • 5,607
  • 14
  • 58
  • 116

1 Answers1

2

First off, in that other SO question, the ES node was a live one so its URL included https.

Your localhost ist almost certainly not going to have https so change it to http:

curl -XPUT -H "Content-Type: application/json" \
     http://localhost:9200/_all/_settings \
     -d '{"index.blocks.read_only_allow_delete": null}'

Other than that, everything looks okay, provided that your ES is running.

When successful, you should receive a simple message:

{"acknowledged":true}

Edit: go with

curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d "{\"index.blocks.read_only_allow_delete\": null}"
Joe - GMapsBook.com
  • 15,787
  • 4
  • 23
  • 68