Making cURL PUT, POST and DELETE requests?

Sometimes Kibana times out when making certain large requests so I think I am forced to do it thru CLI.

Issue is that I do not know how to currently make the sintaxis.

I already generated a api key. For the sake of a example: t567ga-hYw15fgmrt6_123 That would be my API key.

And this is what I am trying to do:

PUT example-temp
{
  "mappings": {
    "properties": {
      "geoip": {
        "properties": {
          "location": { "type": "geo_point" }
        }
      }
    }
  }
}

POST _reindex
{
  "source": {
    "index": "example"
  },
  "dest": {
    "index": "example-temp"
  }
}

DELETE example

PUT example
{
  "mappings": {
    "properties": {
      "geoip": {
        "properties": {
          "location": { "type": "geo_point" }
        }
      }
    }
  }
}

POST _reindex
{
  "source": {
    "index": "example-temp"
  },
  "dest": {
    "index": "example"
  }
}

DELETE example-temp

Thank you for all the help as always

I tried this:

curl -H "Authorization: ApiKey t567ga-hYw15fgmrt6_123" -X POST "http://localhost:9200/_search" -d'
  {
     "query": {
       "match_all": {}
     }
  }'

But I get as a reply:

{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}

Progressing:

curl -H "Authorization: ApiKey t567ga-hYw15fgmrt6_123" -H "Content-Type: application/json"  -X POST "http://localhost:9200/_search" -d'
  {
     "query": {
       "match_all": {}
     }
  }'

I get:

{"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication credentials for REST request [/_search]","header":{"WWW-Authenticate":["Basic realm=\"security\" charset=\"UTF-8\"","ApiKey"]}}],"type":"security_exception","reason":"missing authentication credentials for REST request [/_search]","header":{"WWW-Authenticate":["Basic realm=\"security\" charset=\"UTF-8\"","ApiKey"]}},"status":401}

Well I got it to work BUT it isnt with a api key:

curl --user adminuser:password -H "Content-Type: application/json" -X PUT "http://localhost:9200/example-temp" -d'{
  "mappings": {
    "properties": {
      "geoip": {
        "properties": {
          "location": { "type": "geo_point" }
        }
      }
    }
  }
}'


curl --user adminuser:password -H "Content-Type: application/json" -X POST "http://localhost:9200/_reindex" -d'{
  "source": {
    "index": "example"
  },
  "dest": {
    "index": "example-temp"
  }
}'



curl --user adminuser:password -H "Content-Type: application/json" -X DELETE "http://localhost:9200/example" 




curl --user adminuser:password -H "Content-Type: application/json" -X PUT "http://localhost:9200/example" -d'{
  "mappings": {
    "properties": {
      "geoip": {
        "properties": {
          "location": { "type": "geo_point" }
        }
      }
    }
  }
}'



curl --user adminuser:password -H "Content-Type: application/json" -X POST "http://localhost:9200/_reindex" -d'{
  "source": {
    "index": "example-temp"
  },
  "dest": {
    "index": "example"
  }
}'


curl --user adminuser:password -H "Content-Type: application/json" -X DELETE "http://localhost:9200/example-temp"

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.