How to properly write multiple data points into InfluxDB


I am trying to write multiple data points into InfluxDb using the web API. I can write a single point to the influxDb (Like replacing the command with the first half “Measurements,device=601 value=0.8,value2=120.5,value3=60.007”) but when I tried to build a line command to write multiple data points, I got the error returned by the influxDb:"{“error”:“partial write: unable to parse ‘Measurements,device=601 value=0.8,value2=120.5,value3=60.007\r’: invalid number dropped=0”}\n"
Here’s my code in c#:

static async Task MainAsync()
using (var client = new HttpClient())
client.BaseAddress = new Uri(“http://localhost:8086”);
var content = new ByteArrayContent(Encoding.ASCII.GetBytes(“Measurements,device=601 value=0.8,value2=120.5,value3=60.007\r\nMeasurements,device=601 value=0.8,value2=120.5,value3=60.008”));
var result = await client.PostAsync("/write?db=data", content);
string resultContent = await result.Content.ReadAsStringAsync();

I am new to InfluxDB and I am not sure if using the web API is the right way to write multiple data points. Any comment is welcomed :slight_smile:


Hi @Ferriad_Wang,

Writing points via the HTTP API is a fine way to go, and we recommend that you write multiple points in one batch in order to minimize the overhead of the HTTP connections.

You might also want to take a look at the .Net client libraries.

It looks you are using Windows-style line endings, \r\n. InfluxDB expects Unix line endings, \n. The database sees 60.007\r and doesn’t know what to do with that value, so it throws an error. Try using \n instead of \r\n.

1 Like

Thank you, Noah. the \r ending works well for my system.