# Issues writing multiple points

**URL:** <https://community.influxdata.com/t/issues-writing-multiple-points/1249>\
**Category:** Systems\
**Tags:** influxdb, time-series\
**Created:** [June 10, 2017, 2:29am UTC](https://community.influxdata.com/t/issues-writing-multiple-points/1249 "2017-06-10T02:29:37Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![karanrajpal14](https://avatars.discourse-cdn.com/v4/letter/k/46a35a/32.png) [@karanrajpal14](https://community.influxdata.com/u/karanrajpal14)\
**Post date:** [June 10, 2017, 2:29am UTC](https://community.influxdata.com/t/issues-writing-multiple-points/1249/1 "2017-06-10T02:29:37Z")

</div>

Hey, I’ve been having issues writing multiple points to influxdb using the command prompt on windows. I’m able to write it on linux but I have to press the enter key and then continue adding points which is okay but then I need to automate this behavior using a script or directly send the data in from my sensor.  
I’ve opened up an issue on GitHub. Here’s the link:

> <https://github.com/influxdata/influxdb/issues/8464#issuecomment-307092817>
>
> I'm currently trying to write multiple points into my database using a HTTP call… but I can't seem to get it to work. Even the example call given on your documentation isn't working for me. Here's a run down of the different permutations of calls I've tried and what error I'm facing with them.
> 
> 1 Just one point
> \`curl -i -XPOST 'http://localhost:8086/write?db=sensordata' -d 'flow,host=server01,region=us-west value=0.64'\`
> 
> HTTP/1.1 204 No Content
> Content-Type: application/json
> Request-Id: 1d858abf-4c2d-11e7-832c-000000000000
> X-Influxdb-Version: 1.2.4
> Date: Thu, 08 Jun 2017 09:30:31 GMT
> 
> This works. None of the other permutations that I use below work.
> 
> 2 Two points and no timestamp
> \`curl -i -XPOST 'http://localhost:8086/write?db=sensordata' -d 'flow,host=server01,region=us-west value=0.64 flow,host=server02,region=us-west value=0.65'\`
> 
> HTTP/1.1 400 Bad Request
> Content-Type: application/json
> Request-Id: 4b2a3d3a-4c2d-11e7-832d-000000000000
> X-Influxdb-Version: 1.2.4
> Date: Thu, 08 Jun 2017 09:31:47 GMT
> Content-Length: 135
> 
> {"error":"unable to parse 'flow,host=server01,region=us-west value=0.64 flow,host=server02,region=us-west value=0.65': bad timestamp"}
> 
> 3 Two points and one timestamp
> \`curl -i -XPOST 'http://localhost:8086/write?db=sensordata' -d 'flow,host=server01,region=us-west value=0.64 flow,host=server02 value=1.2 1496914088'\`
> 
> HTTP/1.1 400 Bad Request
> Content-Type: application/json
> Request-Id: 7251f9b5-4c2d-11e7-832e-000000000000
> X-Influxdb-Version: 1.2.4
> Date: Thu, 08 Jun 2017 09:32:53 GMT
> Content-Length: 134
> 
> {"error":"unable to parse 'flow,host=server01,region=us-west value=0.64 flow,host=server02 value=1.2 1496914088': bad timestamp"}
> 
> 4 Two points and two timestamps
> \`curl -i -XPOST 'http://localhost:8086/write?db=sensordata' -d 'flow,host=server01,region=us-west value=0.64 1496914087 flow,host=server02 value=1.2 1496914088'\`
> 
> HTTP/1.1 400 Bad Request
> Content-Type: application/json
> Request-Id: 7251f9b5-4c2d-11e7-832e-000000000000
> X-Influxdb-Version: 1.2.4
> Date: Thu, 08 Jun 2017 09:32:53 GMT
> Content-Length: 134
> 
> {"error":"unable to parse 'flow,host=server01,region=us-west value=0.64 1496914087 flow,host=server02 value=1.2 1496914088': bad timestamp"}

Please have a look at it and help me out here. I’d appreciate any help.  
Thank you!

---

<div class="post-metadata">

**Author:** ![karanrajpal14](https://avatars.discourse-cdn.com/v4/letter/k/46a35a/32.png) [@karanrajpal14](https://community.influxdata.com/u/karanrajpal14)\
**Post date:** [June 11, 2017, 5:27am UTC](https://community.influxdata.com/t/issues-writing-multiple-points/1249/2 "2017-06-11T05:27:15Z")

</div>

Bump. Any suggestions? How does everyone here make use curl to make a HTTP call and write multiple points? I’n not able to add a new line which makes the write fail. Any suggestions would be helpful as I’ve got a lot of data to insert and I’d like to automate it.

---

<div class="post-metadata">

**Author:** ![mark](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/mark/32/778_2.png) [@mark](https://community.influxdata.com/u/mark)\
**Post date:** [June 12, 2017, 1:03am UTC](https://community.influxdata.com/t/issues-writing-multiple-points/1249/3 "2017-06-12T01:03:36Z")

</div>

If you wrote all the lines to a file, say, `line_protocol.txt`, then you should be able to POST with curl along the lines of

```auto
curl -XPOST 'http://localhost:8086/write?db=mydb' -d @line_protocol.txt

```

See also: [POST XML file using cURL command line - Stack Overflow](https://stackoverflow.com/questions/3007253/send-post-xml-file-using-curl-command-line)

---

<div class="post-metadata">

**Author:** ![mark](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/mark/32/778_2.png) [@mark](https://community.influxdata.com/u/mark)\
**Post date:** [June 12, 2017, 3:48pm UTC](https://community.influxdata.com/t/issues-writing-multiple-points/1249/4 "2017-06-12T15:48:32Z")

</div>

Correction: that should be `--data-binary` instead of `-d` (or `--data`). Using `-d` seems to eliminate newlines, creating invalid line protocol.

---

<div class="post-metadata">

**Author:** ![karanrajpal14](https://avatars.discourse-cdn.com/v4/letter/k/46a35a/32.png) [@karanrajpal14](https://community.influxdata.com/u/karanrajpal14)\
**Post date:** [June 13, 2017, 9:11am UTC](https://community.influxdata.com/t/issues-writing-multiple-points/1249/5 "2017-06-13T09:11:39Z")

</div>

Thank you for the reply. While this may work, it will still cause a bottleneck as I have to write it to a file first and curl will have to read from it again. I’m sure there’s a lag there. Also, I don’t think I can use this as File I/O on a micro-controller might not be pretty fast. Can you think of something else?

---

<div class="post-metadata">

**Author:** ![mark](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/mark/32/778_2.png) [@mark](https://community.influxdata.com/u/mark)\
**Post date:** [June 13, 2017, 3:17pm UTC](https://community.influxdata.com/t/issues-writing-multiple-points/1249/6 "2017-06-13T15:17:35Z")

</div>

In bash, I just write multiple newlines inside a quoted string:

```auto
curl -XPOST localhost:8086/write?db=junk --data-binary 'm,tag=a n=1
m,tag=b n=2
m,tag=c n=3
'

```

I don’t know what you have to do to use a multi-line string literal in a Windows command prompt.

---

<div class="post-metadata">

**Author:** ![mark](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/mark/32/778_2.png) [@mark](https://community.influxdata.com/u/mark)\
**Post date:** [June 13, 2017, 8:19pm UTC](https://community.influxdata.com/t/issues-writing-multiple-points/1249/7 "2017-06-13T20:19:56Z")

</div>

To use stdin as the post body for curl, use `--data-binary @-`:

```auto
(for i in $(seq 4096); do echo "ctr,s=$i n=$i"; done) |
  curl -i -XPOST localhost:8086/write?db=junk --data-binary @-

```

---

<div class="post-metadata">

**Author:** ![karanrajpal14](https://avatars.discourse-cdn.com/v4/letter/k/46a35a/32.png) [@karanrajpal14](https://community.influxdata.com/u/karanrajpal14)\
**Post date:** [June 14, 2017, 5:50am UTC](https://community.influxdata.com/t/issues-writing-multiple-points/1249/8 "2017-06-14T05:50:09Z")

</div>

I tried it on both Linux and windows and the issue is the same. I don’t think you’re understanding my PoV. You’re entering the newlines yourself by pressing enter. That works even on my end. What I’m saying is that I need to enter thousands of rows of data and I cannot do them manually since the sensor is sending that data to me. I need to enter a newline programatically. Like how we’ve got “\n” in C. Makes sense?

As for your script, how does it work exactly? Do I have to pass the data as command line arguments? Because that didn’t work for me neither did echoing it and the piping it to the script. Would you please clear that out for me?
