I want to add new connections in storage plugins through my code. Would you please tell how to add or configure connections in storage plugin programmatically in c#.
Is it possible to configure storage plugin connection through command prompt? If yes, 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";
}