# How to send HTTP verbs to ElasticSearch

**URL:** <https://discuss.elastic.co/t/how-to-send-http-verbs-to-elasticsearch/173566>\
**Category:** Elasticsearch\
**Created:** [March 22, 2019, 11:03pm UTC](https://discuss.elastic.co/t/how-to-send-http-verbs-to-elasticsearch/173566 "2019-03-22T23:03:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vincent\_Stevenson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vincent_stevenson/32/48477_2.png) [@Vincent\_Stevenson](https://discuss.elastic.co/u/Vincent_Stevenson)\
**Post date:** [March 22, 2019, 11:03pm UTC](https://discuss.elastic.co/t/how-to-send-http-verbs-to-elasticsearch/173566/1 "2019-03-22T23:03:08Z")

</div>

I am running elasticsearch on my Windows computer on port 9200. I am trying to write a method in C# to create an index, but I keep getting erred out.

Here's a snippet from C#

```auto
string jsonPayload = $"{indexName}";
byte[] data = Encoding.ASCII.GetBytes(jsonPayload);
using (var client = new System.Net.WebClient())
{
	client.UploadData(elasticAddress, "PUT", data);
}

```

Essentially, I'm trying to do what Kibana does from the Dev Tools page: PUT indexname to create an index.

Anyone have advice on how I can use C# to make HTTP calls to my ElasticSearch client running at port 9200? I want to work with HTTP directly, and not go through the Elastic client.

Thanks

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [March 27, 2019, 4:45am UTC](https://discuss.elastic.co/t/how-to-send-http-verbs-to-elasticsearch/173566/2 "2019-03-27T04:45:43Z")

</div>

This is going to send `indexName` bytes in the body of the request, which is not correct.

I would recommend starting with one of the official .NET clients for Elasticsearch, either `Elasticsearch.Net` (low level client) or `NEST` (high level client). I would suggest the high level client unless you have a good reason for using the low level client.

Then, creating and index is

```auto
var elasticAddress= "http://localhost:9200";
var pool = new SingleNodeConnectionPool(new Uri(elasticAddress));
var settings = new ConnectionSettings(pool);

var client = new ElasticClient(settings);

var indexName = "indexName";

var createIndexResponse = client.CreateIndex(indexName);

if (createIndexResponse.IsValid)
{
    Console.WriteLine($"index '{indexName}' created");
}

```

Check out the [client docs for more details](https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/index.html).

---

<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:** [April 24, 2019, 4:45am UTC](https://discuss.elastic.co/t/how-to-send-http-verbs-to-elasticsearch/173566/3 "2019-04-24T04:45:47Z")

</div>

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