-
Notifications
You must be signed in to change notification settings - Fork 183
Closed
Labels
questionFurther information is requestedFurther information is requestedwontfixThis will not be worked onThis will not be worked on
Milestone
Description
Hello, I try to use exemple to import in my influxdb but i have an error and i don't found where is my error :/
My code :
from influxdb_client import InfluxDBClient
from influxdb_client.client.write_api import SYNCHRONOUS
class Daily(namedtuple('Daily', ['name', 'timestamp', 'pdl', 'value', 'measure_type'])):
"""
Named structure - Daily
"""
pass
with InfluxDBClient(url=influxdb_host, token=influxdb_token, org=influxdb_org) as client:
write_api = client.write_api(write_options=SYNCHRONOUS)
daily = Daily(name="test", timestamp=datetime.utcnow(), pdl=pdl, value="25", measure_type="HP")
write_api.write(bucket=influxdb_bucket,
record=daily,
record_measurement_key="name",
record_time_key="timestamp",
record_tag_keys=["measure_type"],
record_field_keys=["value"])
Result :
2021-10-20 11:50:53.945740 - INFO : Connected to MQTT Broker!
Traceback (most recent call last):
File "/app/main.py", line 613, in <module>
write_api.write(bucket=influxdb_bucket,
File "/usr/local/lib/python3.9/site-packages/influxdb_client/client/write_api.py", line 255, in write
results = list(map(write_payload, payloads.items()))
File "/usr/local/lib/python3.9/site-packages/influxdb_client/client/write_api.py", line 253, in write_payload
return self._post_write(_async_req, bucket, org, final_string, payload[0])
File "/usr/local/lib/python3.9/site-packages/influxdb_client/client/write_api.py", line 385, in _post_write
return self._write_service.post_write(org=org, bucket=bucket, body=body, precision=precision,
File "/usr/local/lib/python3.9/site-packages/influxdb_client/service/write_service.py", line 64, in post_write
(data) = self.post_write_with_http_info(org, bucket, body, **kwargs) # noqa: E501
File "/usr/local/lib/python3.9/site-packages/influxdb_client/service/write_service.py", line 168, in post_write_with_http_info
return self.api_client.call_api(
File "/usr/local/lib/python3.9/site-packages/influxdb_client/api_client.py", line 341, in call_api
return self.__call_api(resource_path, method,
File "/usr/local/lib/python3.9/site-packages/influxdb_client/api_client.py", line 171, in __call_api
response_data = self.request(
File "/usr/local/lib/python3.9/site-packages/influxdb_client/api_client.py", line 386, in request
return self.rest_client.POST(url,
File "/usr/local/lib/python3.9/site-packages/influxdb_client/rest.py", line 302, in POST
return self.request("POST", url,
File "/usr/local/lib/python3.9/site-packages/influxdb_client/rest.py", line 252, in request
raise ApiException(http_resp=r)
influxdb_client.rest.ApiException: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json; charset=utf-8', 'X-Platform-Error-Code': 'invalid', 'Date': 'Wed, 20 Oct 2021 11:50:53 GMT', 'Content-Length': '197'})
HTTP response body: {"code":"invalid","message":"unable to parse 'Sensor': missing fields\nunable to parse 'XXXXXXXXXXXXXXXX': missing fields\nunable to parse '25': missing fields\nunable to parse 'HP': missing fields"}
Have you idea ?
Docker image FROM : python:3.9.7-slim
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requestedwontfixThis will not be worked onThis will not be worked on