# Parse Exception from a simple POST request

**URL:** <https://discuss.elastic.co/t/parse-exception-from-a-simple-post-request/148754>\
**Category:** Elasticsearch\
**Created:** [September 17, 2018, 3:29am UTC](https://discuss.elastic.co/t/parse-exception-from-a-simple-post-request/148754 "2018-09-17T03:29:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ben\_Hoffman](https://avatars.discourse-cdn.com/v4/letter/b/71e660/32.png) [@Ben\_Hoffman](https://discuss.elastic.co/u/Ben_Hoffman)\
**Post date:** [September 17, 2018, 3:29am UTC](https://discuss.elastic.co/t/parse-exception-from-a-simple-post-request/148754/1 "2018-09-17T03:29:14Z")

</div>

I am using sockets in C++ to communicate with Elasticsearch. I can communicate with my ELK instance (it is running in a docker compose, the docker files are [here](https://github.com/BenjaFriend/docker-elk)).

Here is the request that I am sending:

```auto
POST /twitter/_doc/1? HTTP/1.1
Content-Type: application/json; charset=UTF-8
Host: 127.0.0.1:9200
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36
'{ "post_date" : "2017-11-16T14:12:12", "message" : "trying out Elasticsearch FROM CPPPPP" }'
Connection: close

```

And here is the response that I am getting from the server:

```auto
HTTP/1.1 400 Bad Request
content-type: application/json; charset=UTF-8
content-length: 163

{"error":{"root_cause":[{"type":"parse_exception","reason":"request body is required"}],"type":"parse_exception","reason":"request body is required"},"status":400}

```

I can confirm that I am sending and receiving this data by counting the bytes being sent and received.

I am confused because when I put that request into the Kibana console, it runs fine.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/0/203c25500485763ee70efca394fb327f5ef8f985.png)

Any ideas on what would be wrong with the request that I am sending?

Here is the C++ code where I create the request:

```auto
	std::string post_http = "";
	post_http += "POST /twitter/_doc/1? HTTP/1.1\n";
	post_http += "Content-Type: application/json; charset=UTF-8\n";
	post_http += "Host: ";
	post_http += aURL;
	post_http += ":9200\n";
	post_http += "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36\n";
	post_http += "'{ \"post_date\" : \"2017-11-16T14:12:12\", ";
	post_http += "\"message\" : \"trying out Elasticsearch FROM CPPPPP\" }'";
	post_http += "\r\nConnection: close\r\n\r\n";

```

---

<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:** [October 15, 2018, 3:29am UTC](https://discuss.elastic.co/t/parse-exception-from-a-simple-post-request/148754/2 "2018-10-15T03:29:18Z")

</div>

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