Search code examples
curlpostinfluxdb

how to pull data from influxdb via API call?


i have pushed the data using the below api call in the database "dbvishnutest"

curl -XPOST http://<localhost>:8086/write?db=dbvishnutest --data-binary "weather,location=us-midwest temperature=82 1465839830100400200"

Now i am trying to pull back the data using the below api call .

curl -i -XPOST -G http://<localhost>:8086/query?pretty=true --data-urlencode "dbvishnutest" --data-urlencode "q=select * from weather where location=us-midwest"

i am getting the below error :

HTTP/1.1 200 OK
Content-Type: application/json
Request-Id: 1966e27f-dc05-11e7-8087-000000000000
X-Influxdb-Build: OSS
X-Influxdb-Version: 1.4.2
X-Request-Id: 1966e27f-dc05-11e7-8087-000000000000
Date: Fri, 08 Dec 2017 10:46:51 GMT
Transfer-Encoding: chunked

{
    "results": [
        {
            "statement_id": 0,
            "error": "database name required"
        }
    ]
}

i am new to influx db , i tried fix i was not able to fix this.

Can someone correct my mistake please ? thanks in advance :)


Solution

  • look careful influx doc

    should specify "db="

    --data-urlencode "db=dbvishnutest"