0

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!

2 Answers 2

2

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);
Sign up to request clarification or add additional context in comments.

Comments

0

Load the curl into Postman; enter image description here

And then select 'Rest Sharp' from the code snippets menu on the right-hand side. enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.