0
votes

How to convert this cURL to RestSharp?

curl -i -XPOST 'http://localhost:8086/write?db=mydb' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64'

This is how one can write records to an InfluxDB instance using cURL but I need the RestSharp equivalent.

Thank you!

1

1 Answers

2
votes

Figured that out so answering my question:

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);