I require to send a HTTP GET request with a content body. Yes I know this is frowned upon but it is technically a legal transaction.
Currently the .NET WebRequest class will fail when attempting to get the request stream as shown below.
string url = "https://someplace.com/api";
var wr = WebRequest.Create(url);
wr.Method = "GET";
string json = JsonConvert.SerializeObject(query);
byte[] byteData = Encoding.UTF8.GetBytes(json);
using (var req = wr.GetRequestStream()) // Exception thrown here
{
req.Write(byteData, 0, byteData.Length);
req.Flush();
}
What other options do I have?
The equivalent CURL command is:
curl -XGET 'localhost:9200/twitter/tweet/_search?pretty' -d'
{
"query" : {
"term" : { "user" : "kimchy" }
}
}'