# Writing HTTP request values to InfluxDB

**URL:** <https://discourse.nodered.org/t/writing-http-request-values-to-influxdb/11074>\
**Category:** General\
**Created:** [13 May 2019 14:33 UTC](https://discourse.nodered.org/t/writing-http-request-values-to-influxdb/11074 "2019-05-13T14:33:21Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [13 May 2019 14:33 UTC](https://discourse.nodered.org/t/writing-http-request-values-to-influxdb/11074/1 "2019-05-13T14:33:21Z")

</div>

As a newbie I discover problems writing measurements to my InfluxDB. The flow writes msg.payload.latest.data to the debug frame but I did not succeed writing msg.payload.latest.data to the database. When I connect InfluxDB Out node (image) errors are generated after deploy was pressed. Can someone give me some advice how to do this?

 ![flowdb](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/77c6306b1e0849d8089e415185cad5141d0fea9c.png)

```auto
[{"id":"ef1759b1.fd5458","type":"tab","label":"NAP Rivieren","disabled":false,"info":""},{"id":"deb83872.9cb878","type":"inject","z":"ef1759b1.fd5458","name":"240'","topic":"","payload":"","payloadType":"date","repeat":"14400","crontab":"","once":true,"onceDelay":0.1,"x":130,"y":120,"wires":[["6ea47c05.07f344"]]},{"id":"6ea47c05.07f344","type":"http request","z":"ef1759b1.fd5458","name":"HTTP Request TL","method":"GET","ret":"obj","url":"https://waterinfo.rws.nl/api/detail?expertParameter=Waterhoogte ___20Oppervlaktewater___ 20t.o.v. ___20Normaal___ 20Amsterdams ___20Peil___ 20in___20cm&locationSlug=Tiel-Waal%28TIEW%29&user=publiek","tls":"","x":346,"y":120,"wires":[["9a26b8fe.0268f8"]]},{"id":"898effc4.20b8b","type":"debug","z":"ef1759b1.fd5458","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.latest.data","x":630,"y":220,"wires":[]},{"id":"be5a1a94.89d3b8","type":"inject","z":"ef1759b1.fd5458","name":"240'","topic":"","payload":"","payloadType":"date","repeat":"14400","crontab":"","once":true,"onceDelay":0.1,"x":130,"y":220,"wires":[["5ab297d7.54e4e8"]]},{"id":"5ab297d7.54e4e8","type":"http request","z":"ef1759b1.fd5458","name":"HTTP Request RH","method":"GET","ret":"obj","url":"https://waterinfo.rws.nl/api/detail?expertParameter=Waterhoogte___20Oppervlaktewater ___20t.o.v.___ 20Normaal ___20Amsterdams___ 20Peil ___20in___ 20cm&locationSlug=Grebbe%28GREB%29&user=publiek","tls":"","x":346,"y":220,"wires":[["898effc4.20b8b"]]},{"id":"9a26b8fe.0268f8","type":"debug","z":"ef1759b1.fd5458","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.latest.data","x":630,"y":120,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [13 May 2019 15:20 UTC](https://discourse.nodered.org/t/writing-http-request-values-to-influxdb/11074/2 "2019-05-13T15:20:41Z")

</div>

Would be helpful to see the errors as well otherwise it is hard to see what is going on.

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [14 May 2019 06:55 UTC](https://discourse.nodered.org/t/writing-http-request-values-to-influxdb/11074/3 "2019-05-14T06:55:05Z")

</div>

Hi. Below the error message in the debug frame.

```auto
Error: A 400 Bad Request error occurred: {"error":"unable to parse 'naprhenen explanation=\"Waterhoogte t.o.v. NAP\",latest=[object Object],location=\"Grebbe\",range=[object Object],[object Object],[object Object],[object Object],related=[object Object],title=\"Waterhoogte Oppervlaktewater t.o.v. Normaal Amsterdams Peil in cm\"': invalid boolean"}

```

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [14 May 2019 07:29 UTC](https://discourse.nodered.org/t/writing-http-request-values-to-influxdb/11074/4 "2019-05-14T07:29:28Z")

</div>

The debug output does not match with your flow.  
You cannot send the http request output directly to influx without giving it some properties.

Can you post the full flow ?

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [14 May 2019 08:12 UTC](https://discourse.nodered.org/t/writing-http-request-values-to-influxdb/11074/5 "2019-05-14T08:12:57Z")

</div>

Thanks (again) for your help! Below the flow.

```auto
[{"id":"84366ae3.ae6af8","type":"tab","label":"Forum","disabled":false,"info":""},{"id":"2afe8879.31fad8","type":"debug","z":"84366ae3.ae6af8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.latest.data","x":690,"y":120,"wires":[]},{"id":"997c8c6f.6b3cc","type":"inject","z":"84366ae3.ae6af8","name":"240'","topic":"","payload":"","payloadType":"date","repeat":"14400","crontab":"","once":true,"onceDelay":0.1,"x":210,"y":160,"wires":[["86f0906b.5eaaa"]]},{"id":"86f0906b.5eaaa","type":"http request","z":"84366ae3.ae6af8","name":"HTTP Request RH","method":"GET","ret":"obj","url":"https://waterinfo.rws.nl/api/detail?expertParameter=Waterhoogte ___20Oppervlaktewater___ 20t.o.v. ___20Normaal___ 20Amsterdams ___20Peil___ 20in___20cm&locationSlug=Grebbe%28GREB%29&user=publiek","tls":"","x":426,"y":160,"wires":[["2afe8879.31fad8","283d7e14.bb5192"]]},{"id":"283d7e14.bb5192","type":"influxdb out","z":"84366ae3.ae6af8","influxdb":"e0390dc7.802ec","name":"naprhenen (192.168.2.185)","measurement":"number","precision":"","retentionPolicy":"","x":700,"y":200,"wires":[]},{"id":"e0390dc7.802ec","type":"influxdb","z":"","hostname":"192.168.2.185","port":"8086","protocol":"http","database":"naprhenen","name":"naprhenen","usetls":false,"tls":""}]

```

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [14 May 2019 08:25 UTC](https://discourse.nodered.org/t/writing-http-request-values-to-influxdb/11074/6 "2019-05-14T08:25:08Z")

</div>

It looks to me as though you've passed the data to the http-request in the wrong way. It is the request that has failed, not InfluxDB?

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [14 May 2019 08:26 UTC](https://discourse.nodered.org/t/writing-http-request-values-to-influxdb/11074/7 "2019-05-14T08:26:31Z")

</div>

You are trying to insert the full msg.payload, while you only want to insert 1 number, correct?

```auto
[{"id":"dddf8f83.722368","type":"debug","z":"74695533.ac3f94","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.latest.data","x":690,"y":120,"wires":[]},{"id":"f10d7bad.54f5f8","type":"inject","z":"74695533.ac3f94","name":"240'","topic":"","payload":"","payloadType":"date","repeat":"14400","crontab":"","once":true,"onceDelay":0.1,"x":210,"y":160,"wires":[["6e09bb46.0df33c"]]},{"id":"6e09bb46.0df33c","type":"http request","z":"74695533.ac3f94","name":"HTTP Request RH","method":"GET","ret":"obj","url":"https://waterinfo.rws.nl/api/detail?expertParameter=Waterhoogte ___20Oppervlaktewater___ 20t.o.v. ___20Normaal___ 20Amsterdams ___20Peil___ 20in___20cm&locationSlug=Grebbe%28GREB%29&user=publiek","tls":"","x":426,"y":160,"wires":[["dddf8f83.722368","7db54950.5f3548"]]},{"id":"4573f40f.73fa1c","type":"influxdb out","z":"74695533.ac3f94","influxdb":"f3388bfa.998be","name":"naprhenen (192.168.2.185)","measurement":"number","precision":"","retentionPolicy":"","x":780,"y":242,"wires":[]},{"id":"7db54950.5f3548","type":"change","z":"74695533.ac3f94","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.latest.data","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":542,"y":220,"wires":[["4573f40f.73fa1c"]]},{"id":"f3388bfa.998be","type":"influxdb","z":"","hostname":"192.168.2.185","port":"8086","protocol":"http","database":"naprhenen","name":"naprhenen","usetls":false,"tls":""}]

```

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [14 May 2019 08:39 UTC](https://discourse.nodered.org/t/writing-http-request-values-to-influxdb/11074/8 "2019-05-14T08:39:40Z")

</div>

@ TotallyInformation:  
I'm afraid you're right 😉

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [14 May 2019 08:42 UTC](https://discourse.nodered.org/t/writing-http-request-values-to-influxdb/11074/9 "2019-05-14T08:42:47Z")

</div>

Hi Bakman2. Still no "overstroming" here and thanks for helping. Your flow runs without errors. You're right, I only want to use one number (waterhoogte in cm) and now struggling to write this value to the DB ☹

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [14 May 2019 15:35 UTC](https://discourse.nodered.org/t/writing-http-request-values-to-influxdb/11074/10 "2019-05-14T15:35:01Z")

</div>

Hi Bakman2, can you tell me what I have to fill in the field below? I did several tries so far but none writes the value in the database.

 ![forum](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/237536a385d6e11fda98a37db8873d822556324c.png)

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [14 May 2019 16:33 UTC](https://discourse.nodered.org/t/writing-http-request-values-to-influxdb/11074/11 "2019-05-14T16:33:22Z")

</div>

What are you using in influx, telegraf ?

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [14 May 2019 16:45 UTC](https://discourse.nodered.org/t/writing-http-request-values-to-influxdb/11074/12 "2019-05-14T16:45:36Z")

</div>

I use InfluxDB and write only that value (waterhoogte) in the database, nothing else. The same as in another database I use, below the Influx output of "select \* from dbname" of that database.

 ![Knipsel](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/00982d3fb8f2b9786e0619f3e3bceb2c7921afb9.png)

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [15 May 2019 05:56 UTC](https://discourse.nodered.org/t/writing-http-request-values-to-influxdb/11074/13 "2019-05-15T05:56:29Z")

</div>

One issue with InfluxDB is that, once you've written a certain data type to a measurement, you can't then change the type. So if you wrote the text of the error message and then try to write a number, that will fail.

Either way, assuming you now have the request working, we need to see the actual error that InfluxDB is generating.

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [15 May 2019 08:14 UTC](https://discourse.nodered.org/t/writing-http-request-values-to-influxdb/11074/14 "2019-05-15T08:14:51Z")

</div>

Hi Julian. To prevent the problem you describe I now have created a new Influx database and tried to write to the DB (with the text below in the Influx DB Out Node measurement field) without succes:

number  
.msg.payload.latest.data  
.payload.latest.data  
.latest.data

None of them worked, The NodeRED debug screen show the right value 601.

![debug](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/09b34b1eddee822f9a28a245b850966d92efb445.png)

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [15 May 2019 08:25 UTC](https://discourse.nodered.org/t/writing-http-request-values-to-influxdb/11074/15 "2019-05-15T08:25:14Z")

</div>

That is the output from the request, it doesn't show us what is happening with InfluxDB. You need to share some kind of output from it otherwise we can't know what is going on.

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [15 May 2019 08:53 UTC](https://discourse.nodered.org/t/writing-http-request-values-to-influxdb/11074/16 "2019-05-15T08:53:58Z")

</div>

No problem to post that info but I really don't know how the get it out of InfluxDB. I've installed Telegraf but so far no success viewing any errorlog.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [15 May 2019 11:07 UTC](https://discourse.nodered.org/t/writing-http-request-values-to-influxdb/11074/17 "2019-05-15T11:07:01Z")

</div>

Point is, is that you will have to specify the database, table and the field(s).

Example for telegraf.

Function node:

```auto
lux = msg.payload.CurrentAmbientLightLevel

msg.payload = [
    {
        measurement:"homeautomation",
        fields: {
           lux:lux
        },
        tags:{
            homeautomation:"light_sensor1"
        },
        timestamp: new Date()
    }];

return msg

```

Connect this to a `influx batch` node.  
`tags` are optional.

Then you can `select lux from homeautomation`

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [15 May 2019 11:27 UTC](https://discourse.nodered.org/t/writing-http-request-values-to-influxdb/11074/18 "2019-05-15T11:27:25Z")

</div>

Thanks for helping!

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [15 May 2019 14:23 UTC](https://discourse.nodered.org/t/writing-http-request-values-to-influxdb/11074/19 "2019-05-15T14:23:23Z")

</div>

> [@HaVi](#):
>
> No problem to post that info but I really don't know how the get it out of InfluxDB. I've installed Telegraf but so far no success viewing any errorlog.

I think that the log should be accessible from something like (I'm not at my Pi's) `journalctl influxdb`. But I would expect the InfluxDB node to produce some output as well.

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [16 May 2019 08:05 UTC](https://discourse.nodered.org/t/writing-http-request-values-to-influxdb/11074/20 "2019-05-16T08:05:32Z")

</div>

For now most seems to work and the payload contains what I need as shown in the NodeRED debugger. Only writing the payload to the Influx database is still not working, no errors are reported after deploying the flow and Chronograf also does not show errors. The Influx command "select \* from Test" does not show errors but also no values. Any suggestions to write the payload to the database are welcome.

```auto
[{"id":"e01e747b.b23d98","type":"tab","label":"Alleen waarde","disabled":false,"info":""},{"id":"be5d4c7.8bd90b","type":"debug","z":"e01e747b.b23d98","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":670,"y":200,"wires":[]},{"id":"792d7094.7136b","type":"inject","z":"e01e747b.b23d98","name":"240'","topic":"","payload":"","payloadType":"date","repeat":"14400","crontab":"","once":true,"onceDelay":0.1,"x":130,"y":220,"wires":[["82b59b92.ef6288"]]},{"id":"82b59b92.ef6288","type":"http request","z":"e01e747b.b23d98","name":"HTTP Request RH","method":"GET","ret":"obj","url":"https://waterinfo.rws.nl/api/detail?expertParameter=Waterhoogte ___20Oppervlaktewater___ 20t.o.v. ___20Normaal___ 20Amsterdams ___20Peil___ 20in___20cm&locationSlug=Grebbe%28GREB%29&user=publiek","tls":"","x":346,"y":220,"wires":[["d14b8d0e.6af22"]]},{"id":"d14b8d0e.6af22","type":"function","z":"e01e747b.b23d98","name":"rhenen","func":"msg.payload = {\n rhenen: msg.payload.latest.data\n}\nreturn msg;","outputs":1,"noerr":0,"x":460,"y":300,"wires":[["be5d4c7.8bd90b","71f67ffa.a3d96"]]},{"id":"71f67ffa.a3d96","type":"influxdb out","z":"e01e747b.b23d98","influxdb":"5d261c0f.e93024","name":"Test (192.168.2.185)","measurement":"msg.payload","precision":"","retentionPolicy":"","x":660,"y":360,"wires":[]},{"id":"5d261c0f.e93024","type":"influxdb","z":"","hostname":"192.168.2.185","port":"8086","protocol":"http","database":"Test","name":"Test","usetls":false,"tls":""}]

```

 ![forum](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/c/ce22293e3351e04f921632b90f7b906573e429fc.png)

[Next page](https://discourse.nodered.org/t/writing-http-request-values-to-influxdb/11074.md?page=2)
