【问题标题】:Convert cURL (--data-binary) Post Command to RestSharp Code将 cURL (--data-binary) Post 命令转换为 RestSharp 代码
【发布时间】:2016-10-01 23:02:12
【问题描述】:

如何将此 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 等效项。

谢谢!

【问题讨论】:

    标签: curl restsharp


    【解决方案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);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-28
      • 1970-01-01
      • 2022-07-08
      • 1970-01-01
      相关资源
      最近更新 更多