# InfluxDB 1.8: Getting ApiException using influxdb\_client and Python

**URL:** <https://community.influxdata.com/t/influxdb-1-8-getting-apiexception-using-influxdb-client-and-python/15887>\
**Category:** Systems\
**Tags:** influxdb, windows, flux\
**Created:** [September 7, 2020, 11:44am UTC](https://community.influxdata.com/t/influxdb-1-8-getting-apiexception-using-influxdb-client-and-python/15887 "2020-09-07T11:44:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andre\_S](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/andre_s/32/5587_2.png) [@Andre\_S](https://community.influxdata.com/u/Andre_S)\
**Post date:** [September 7, 2020, 11:44am UTC](https://community.influxdata.com/t/influxdb-1-8-getting-apiexception-using-influxdb-client-and-python/15887/1 "2020-09-07T11:44:51Z")

</div>

Hello Guys  
I used to query my influxdb data using Python, the influxdb library and DataFrameClient. The Python API states to use the newer ([influxdb-client](https://pypi.org/project/influxdb-client/)) for v1.8+ and v2. As we are running Influxdb v1.8.1 I decided to switch to the influxdb-client and rework my Jupyter Notebooks. So I enabled Flux and tried to query the data using Pandas DataFrames (with the help of DataFrame and [Flux](https://docs.influxdata.com/influxdb/v1.8/flux/get-started/query-influxdb/) examples). Using

```auto
from influxdb_client import InfluxDBClient, Point, Dialect
from influxdb_client.client.write_api import SYNCHRONOUS
client = InfluxDBClient(url="http://localhost:8086", token="username:password")
query_api = client.query_api()

df = query_api.query_data_frame('from(bucket:"MyDatabase/autogen") '
                                    '|> range(start: 2020-08-25T00:00:00Z, stop:2020-08-25T01:00:00Z)'
                                    '|> filter(fn: (r) => r._measurement == "MyMeasurement" and r._field == "MyColumn"')

```

I get the following Error:

```auto
ApiException: (500)
Reason: Internal Server Error
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Request-Id': 'ba3e82d7-f0ef-11ea-8b7e-00155d6fb6df', 'X-Influxdb-Build': 'OSS', 'X-Influxdb-Error': 'loc 1:103-1:187: expected RPAREN, got EOF', 'X-Influxdb-Version': '1.8.1', 'X-Request-Id': 'ba3e82d7-f0ef-11ea-8b7e-00155d6fb6df', 'Date': 'Mon, 07 Sep 2020 09:51:40 GMT', 'Content-Length': '54'})
HTTP response body: b'{"error":"loc 1:103-1:187: expected RPAREN, got EOF"}\n'

```

Leaving out the filter I get a response of a List with several tables but not the desired Information for the Measurement. Moreover I’m using “database/retention policy” for the bucket and “username:password” for the authentification token as stated for the v1.8/v2 compatibility. I also tried to add the `|> yield()` -Statement but without success, still the same error.

Does someone know how to use the Flux filter properly regarding influxdb-client and Python? Do we have to switch to Influxdb v2?

I’m running Python 3.7.4, InfluxDB 1.8.1, influxdb-client 1.10.0 and pandas 1.0.3 on Windows 10.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![philjb](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/philjb/32/5405_2.png) [@philjb](https://community.influxdata.com/u/philjb)\
**Post date:** [September 8, 2020, 2:27am UTC](https://community.influxdata.com/t/influxdb-1-8-getting-apiexception-using-influxdb-client-and-python/15887/2 "2020-09-08T02:27:59Z")

</div>

You’re just missing the close paren for the filter method inside the flux query (very end of your query).

---

<div class="post-metadata">

**Author:** ![Andre\_S](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/andre_s/32/5587_2.png) [@Andre\_S](https://community.influxdata.com/u/Andre_S)\
**Post date:** [September 8, 2020, 7:25am UTC](https://community.influxdata.com/t/influxdb-1-8-getting-apiexception-using-influxdb-client-and-python/15887/3 "2020-09-08T07:25:32Z")

</div>

Thanks a lot. The struggle with this small mistake was real 😅  
One more thing:  
Why is the DataFrameClient of influxdb and its  
`client.query("SELECT MyColumn FROM MyMeasurement where time >= '2020-08-25 00:00:00' and time <'2020-08-25 01:00:00'")`  
much faster than the InfluxDBClient of influxdb\_client and the

```
query_api().query_data_frame('from(bucket:"MyDatabase/autogen") 
                        '|> range(start: 2020-08-25T00:00:00Z, stop:2020-08-25T01:00:00Z)
                        '|> filter(fn: (r) => r._measurement == "MyMeasurement" and r._field == "MyColumn")')

```

?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/3X/2/f/2feb065bdfd5e4b7728243aa3b9192ad3e8447c1.png) [@system](https://community.influxdata.com/u/system)\
**Post date:** [September 8, 2020, 8:25am UTC](https://community.influxdata.com/t/influxdb-1-8-getting-apiexception-using-influxdb-client-and-python/15887/4 "2020-09-08T08:25:37Z")

</div>

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.
