# Error calling Influx API Service

**URL:** https://community.influxdata.com/t/error-calling-influx-api-service/12047
**Category:** InfluxDB 2
**Created:** [November 23, 2019, 1:58pm UTC](https://community.influxdata.com/t/error-calling-influx-api-service/12047 "2019-11-23T13:58:49Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ErickYataco](https://avatars.discourse-cdn.com/v4/letter/e/ee59a6/32.png) [@ErickYataco](https://community.influxdata.com/u/ErickYataco)
#### Post date: [November 23, 2019, 1:58pm UTC](https://community.influxdata.com/t/error-calling-influx-api-service/12047/1 "2019-11-23T13:58:50Z")

</div>

i try to replicate this code in a simple nodejs code

```auto
curl -XPOST "http://localhost:9999/api/v2/write?org=YOUR_ORG&bucket=YOUR_BUCKET&precision=s" \
  --header "Authorization: Token YOURAUTHTOKEN" \
  --data-raw "mem,host=host1 used_percent=23.43234543 1556896326"

```

```auto
const axios = require('axios')
const qs = require('qs')

async function influxd(){

    const options = {
        
      url: 'http://ec2-public-ip:9999/api/v2/write?org=something&bucket=something&precisions=s',
      method: 'POST',
      headers: {
        'Authorization': 'Token 1LNrO7r1NPWDAwYtZpl-0Zd1EjSSwPhimoKZ8PUcTSbFFhqCIUUjYVYIA6ReFfqYUMuqpIPF1x33-pCcsp99fA==',
        'Content-Type': "text/plain; charset=utf-8"
      },
      timeout: 0,
      'body': qs.stringify('cpu,host=host1 usage_user=3.8234,usage_system=4.23874 1556892726597397000')
    }
  
    const response = await axios(options).catch(error=>console.log(error))

    return response
  
}

```

and i receive this error

```
 data: { code: 'invalid', message: 'writing requires points' } },

```

what i’m doing wrong?

---

<div class="post-metadata">

### Author: ![noahcrowley](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/noahcrowley/32/818_2.png) [@noahcrowley](https://community.influxdata.com/u/noahcrowley)
#### Post date: [November 26, 2019, 4:51pm UTC](https://community.influxdata.com/t/error-calling-influx-api-service/12047/2 "2019-11-26T16:51:32Z")

</div>

A few issues:

- I think the `'body'` parameter should be `data`, and you can just pass it a string. Not sure why you need `qs` here.
- Make sure that your Org uses the orgID and not the org name.
- The timestamp in the line protocol you’re submitting uses nanosecond precision, so remove the `precisions=s` from the URL.

The following code worked for me:

```auto
const axios = require('axios')

async function influxd(){

    const options = {
        
      url: 'http://localhost:9999/api/v2/write?org=org&bucket=bucket',
      method: 'POST',
      headers: {
        'Authorization': 'Token token',
        'Content-Type': "text/plain; charset=utf-8"
      },
      timeout: 0,
      data: 'cpu,host=host1 usage_user=3.8234,usage_system=4.23874 1574786860084000000'
    }
  
    const response = await axios(options).catch(error=>console.log(error))

    return response
  
}

```
