# How can I receive data using subscription

**URL:** <https://community.influxdata.com/t/how-can-i-receive-data-using-subscription/11662>\
**Category:** Systems\
**Tags:** influxdb\
**Created:** [October 19, 2019, 7:40am UTC](https://community.influxdata.com/t/how-can-i-receive-data-using-subscription/11662 "2019-10-19T07:40:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![taurej](https://avatars.discourse-cdn.com/v4/letter/t/9de053/32.png) [@taurej](https://community.influxdata.com/u/taurej)\
**Post date:** [October 19, 2019, 7:40am UTC](https://community.influxdata.com/t/how-can-i-receive-data-using-subscription/11662/1 "2019-10-19T07:40:53Z")

</div>

Hi Team,

I have created a subscription in influxdb when I am inserting data in influxdb it is inserting successfully and it showing log of inserted data. and that subscription URL also called we confirmed by a log file But we are not able to read inserted data on subscription endpoint either through get or post method or request body. Please help me to get inserted data. The documentation also does not have any example or reference. Thank you.

---

<div class="post-metadata">

**Author:** ![rawkode](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/rawkode/32/5161_2.png) [@rawkode](https://community.influxdata.com/u/rawkode)\
**Post date:** [October 23, 2019, 10:35am UTC](https://community.influxdata.com/t/how-can-i-receive-data-using-subscription/11662/2 "2019-10-23T10:35:34Z")

</div>

Hi @taurej,

Can you please provide the GET / POST requests you’re attempting to perform and any response?

---

<div class="post-metadata">

**Author:** ![taurej](https://avatars.discourse-cdn.com/v4/letter/t/9de053/32.png) [@taurej](https://community.influxdata.com/u/taurej)\
**Post date:** [October 23, 2019, 5:33pm UTC](https://community.influxdata.com/t/how-can-i-receive-data-using-subscription/11662/3 "2019-10-23T17:33:58Z")

</div>

Hi @rawkode,

I have added an end point to influxdb subscription as [http://ipaddress:4003/users/getdatadevice/write](http://ipaddress:4003/users/getdatadevice/write) to receive inserted data if any data is inserted While I am inserting data using API or CLI, influxdb reaching the end point I have added but I could not able to get what is the data it is posting. I am using nodejs Please help me to read data. Thank you.

---

<div class="post-metadata">

**Author:** ![rawkode](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/rawkode/32/5161_2.png) [@rawkode](https://community.influxdata.com/u/rawkode)\
**Post date:** [October 24, 2019, 12:25pm UTC](https://community.influxdata.com/t/how-can-i-receive-data-using-subscription/11662/4 "2019-10-24T12:25:34Z")

</div>

Hi,

So, `http://ipaddress:4003/users/getdatadevice/write` is a NodeJS application?

Are you able to share the code you have that isn’t working?

---

<div class="post-metadata">

**Author:** ![taurej](https://avatars.discourse-cdn.com/v4/letter/t/9de053/32.png) [@taurej](https://community.influxdata.com/u/taurej)\
**Post date:** [October 24, 2019, 1:00pm UTC](https://community.influxdata.com/t/how-can-i-receive-data-using-subscription/11662/5 "2019-10-24T13:00:09Z")

</div>

Hi @rawkode,  
Yes this is the NodeJS application.  
Below is the code where I want to read data from subscription.  
I created the subscription for this URL  
[http://ipaddress:4003/users/getdatadevice](http://ipaddress:4003/users/getdatadevice)

The following response we are getting from the test.txt log file. But actual inserted data is not logged.

{}{“host”:“34.73.96.242:4003”,“user-agent”:“InfluxDBClient”,“content-length”:“760”,“content-type”:“”,“accept-encoding”:“gzip”}undefinedundefined

```
router.post('/getdatadevice/write', function(req, res, next){

var str = JSON.stringify(req.body) + JSON.stringify(req.headers) + JSON.stringify(res.body) + JSON.stringify(res.headers);
    console.log(str);	
fs.writeFile("test.txt", str + '\n', function(err) {

	if(err) {
		return console.log(err);
		res.json(err)
	}
	res.status(200).json({'message':'successfully'})
}); 
});

```

---

<div class="post-metadata">

**Author:** ![reginaldg](https://avatars.discourse-cdn.com/v4/letter/r/51bf81/32.png) [@reginaldg](https://community.influxdata.com/u/reginaldg)\
**Post date:** [September 24, 2020, 2:08pm UTC](https://community.influxdata.com/t/how-can-i-receive-data-using-subscription/11662/6 "2020-09-24T14:08:26Z")

</div>

@taurej have you been able to figure this out yet? We have the exact same problem where kapacitor works but not a direct subscription with an http endpoint.

Any pointers are much much appreciated 🙂 Thank you.
