The request retrieves data in JSON format using the InfluxDB 2.1.1 API

Hi all,
I am using InfluxDB v2.1.1 (Docker version).
I like to use the API flux query with output in JSON format. I have already completed various steps, but the output is still in CSV format.

API URL: http://localhost:8086/api/v2/query?orgID=0e83aa0f418aba6e

Header :

Authorization: Token <Token key>
Accept-Encoding:gzip
Accept:application/json
Content-type:application/json

request body :

{

    "dialect": {

    "annotations": [

      "datatype"

    ],

    "commentPrefix": "#",

    "dateTimeFormat": "RFC3339",

    "delimiter": ",",

    "header": true

  },

    "now": "2022-04-19T14:15:22Z",

    "params": {"mybucket":"cmt"},

    "query":  from(bucket: \"cmt\")|> range(start: -15d)   |> filter(fn: (r) => r[\"_measurement\"] == \"cmt\") |> filter(fn: (r) => r[\"sensorid\"] == \"sensorxx1\")  ",

    "type": "flux"

}

OUTPUT: I received the following format but I would like JSON format

#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string,string
,result,table,_start,_stop,_time,_value,_field,_measurement,sensorid
,_result,0,2022-04-04T14:15:22Z,2022-04-19T14:15:22Z,2022-04-05T06:00:00Z,12474,sensor,cmt,sensorxx1

it is possible to Receive flux query results in JSON format (via HTTP API), what is the mistake? where I will modify or correct the API request?
can please guide me

@iyboobalan The /api/v2/query endpoint only returns annotated CSV. Here’s a feature proposal to enable Flux to return results as JSON: As a user I want to interact with Flux via JSON · Issue #20034 · influxdata/influxdb · GitHub

In the mean time, you could use InfluxQL and the v1 compatibility API /query endpoint to return results as JSON (like in InfluxDB 1.x). Here’s some more information:

thank you so much.
regards.
Boobalan.S
பூபாலன்.சி