# C# sending a get request with a body to ElasticSearch

**URL:** <https://discuss.elastic.co/t/c-sending-a-get-request-with-a-body-to-elasticsearch/205758>\
**Category:** Elasticsearch\
**Created:** [October 29, 2019, 9:04pm UTC](https://discuss.elastic.co/t/c-sending-a-get-request-with-a-body-to-elasticsearch/205758 "2019-10-29T21:04:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_McGovern](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matt_mcgovern/32/90131_2.png) [@Matt\_McGovern](https://discuss.elastic.co/u/Matt_McGovern)\
**Post date:** [October 29, 2019, 9:04pm UTC](https://discuss.elastic.co/t/c-sending-a-get-request-with-a-body-to-elasticsearch/205758/1 "2019-10-29T21:04:01Z")

</div>

I'm trying to return the data from an existing visualization, called from an external source (written in C#). This can be done in Postman using a GET with a body request (this body copied from the request found when "Inspecting" the visualization).

When doing this in C#, I run into the problem with the GET request does not allow content-body to be attached, which apparently is common. Any idea on how to get around this, since the query from ElasticSearch has the body in the request?

Am I going about this the wrong way? I just need to return the data from the visualization.

---

<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:** [October 29, 2019, 11:38pm UTC](https://discuss.elastic.co/t/c-sending-a-get-request-with-a-body-to-elasticsearch/205758/2 "2019-10-29T23:38:50Z")

</div>

The Elasticsearch APIs that accept a `GET` with a body will also accept a `POST` with a body for those languages/frameworks that do not allow sending a `GET` with a body, which C#/.NET BCL HTTP libraries do not allow.

---

<div class="post-metadata">

**Author:** ![Matt\_McGovern](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matt_mcgovern/32/90131_2.png) [@Matt\_McGovern](https://discuss.elastic.co/u/Matt_McGovern)\
**Post date:** [October 30, 2019, 1:43pm UTC](https://discuss.elastic.co/t/c-sending-a-get-request-with-a-body-to-elasticsearch/205758/3 "2019-10-30T13:43:49Z")

</div>

The Elasticsearch API I'm calling needs a GET with a body in this case. I'm calling a visualization and trying to return the data. That API is rejecting a POST for the same request.

Is it possible to save the Visualization, or perhaps a saved query, and just call that?

---

<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:** [November 3, 2019, 4:03pm UTC](https://discuss.elastic.co/t/c-sending-a-get-request-with-a-body-to-elasticsearch/205758/4 "2019-11-03T16:03:27Z")

</div>

> [@Matt\_McGovern](#):
>
> I'm calling a visualization and trying to return the data. That API is rejecting a POST for the same request.

That sounds like a Kibana API rather than an Elasticsearch API?

---

<div class="post-metadata">

**Author:** ![Matt\_McGovern](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matt_mcgovern/32/90131_2.png) [@Matt\_McGovern](https://discuss.elastic.co/u/Matt_McGovern)\
**Post date:** [November 4, 2019, 3:18pm UTC](https://discuss.elastic.co/t/c-sending-a-get-request-with-a-body-to-elasticsearch/205758/5 "2019-11-04T15:18:08Z")

</div>

I was eventually able to do the GET with attached body by using curl, and calling the curl as an external process from my c# code. After reading much on the subject, I find that .NET and much of the world do not support a GET with an attached  
body, even if the HTTP model supports it.

---

<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:** [December 2, 2019, 3:18pm UTC](https://discuss.elastic.co/t/c-sending-a-get-request-with-a-body-to-elasticsearch/205758/6 "2019-12-02T15:18:14Z")

</div>

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