This question already has an answer here:
-
How to create connection in storage plugin of Apache Drill Programmatically in c#
2 answers
I want to create Storage Plugin through C#(.NET) code, when Drill is install in some other system(not in local).?
Is it Possible?? If yes then how.?
I found out some solution for that:
var request = (HttpWebRequest)WebRequest.Create(url);
var postData = "name=" + name + "&config=" + config;
var data = Encoding.ASCII.GetBytes(postData);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
using (var stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
var response = (HttpWebResponse)request.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
if (responseString != null)
{
var jsonObject = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(responseString);
return jsonObject.result == "success";
}