Search code examples
javascripthttp-headersinfluxdb

Has Influx 1.8.3 support for application/json body in InfluxDB API


On arm devices there is not available v2.0 build so far.

Is it possible to query db on v1.8.3 in similar way like this:

let response = await fetch('http://localhost:8086/query', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json;charset=utf-8'
  },
  body: JSON.stringify({
    "db":"test",
    "q":"select * from measurement"
  })
});

Or application/x-www-form-urlencoded is the only applicable format for query?


Solution

  • Yes, I believe the 1.x /query endpoint for InfluxQL queries only takes urlencoded data. See these docs: https://docs.influxdata.com/influxdb/v1.8/tools/api/#query-http-endpoint

    You can use URLSearchParams in the fetch api to set url query params.