如何将此cURL转换为RestSharp?
curl -i -XPOST'http://localhost:8086/write?db=mydb' - data-binary'cpu_load_short,host = server01,region = us-west value = 0.64'
这是使用cURL将记录写入InfluxDB实例的方法,但我需要RestSharp等效项。
谢谢!
答案 0 :(得分:1)
想出来回答我的问题:
var client = new RestClient("http://localhost:8086");
client.Authenticator = new HttpBasicAuthenticator("username", "password");
var request = new RestRequest ("write?db=mydb", Method.POST);
request.AddParameter("text/plain", "cpu_load_short,host=server01,region=us-west value=0.64", ParameterType.RequestBody);
IRestResponse response = client.Execute (request);
var content = response.Content;
Console.WriteLine (content);