# Making cURL PUT, POST and DELETE requests?

**URL:** <https://discuss.elastic.co/t/making-curl-put-post-and-delete-requests/271235>\
**Category:** Elasticsearch\
**Created:** [April 26, 2021, 9:42am UTC](https://discuss.elastic.co/t/making-curl-put-post-and-delete-requests/271235 "2021-04-26T09:42:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![riahc3](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@riahc3](https://discuss.elastic.co/u/riahc3)\
**Post date:** [April 26, 2021, 9:42am UTC](https://discuss.elastic.co/t/making-curl-put-post-and-delete-requests/271235/1 "2021-04-26T09:42:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![riahc3](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@riahc3](https://discuss.elastic.co/u/riahc3)\
**Post date:** [April 26, 2021, 9:49am UTC](https://discuss.elastic.co/t/making-curl-put-post-and-delete-requests/271235/2 "2021-04-26T09:49:31Z")

</div>

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}`

---

<div class="post-metadata">

**Author:** ![riahc3](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@riahc3](https://discuss.elastic.co/u/riahc3)\
**Post date:** [April 26, 2021, 9:53am UTC](https://discuss.elastic.co/t/making-curl-put-post-and-delete-requests/271235/3 "2021-04-26T09:53:21Z")

</div>

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}`

---

<div class="post-metadata">

**Author:** ![riahc3](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@riahc3](https://discuss.elastic.co/u/riahc3)\
**Post date:** [April 26, 2021, 10:46am UTC](https://discuss.elastic.co/t/making-curl-put-post-and-delete-requests/271235/4 "2021-04-26T10:46:44Z")

</div>

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"
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 24, 2021, 10:47am UTC](https://discuss.elastic.co/t/making-curl-put-post-and-delete-requests/271235/5 "2021-05-24T10:47:06Z")

</div>

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