-
Notifications
You must be signed in to change notification settings - Fork 187
Description
Hi, i am having trouble sending data to my influxdb cloud instance in JSON format using Python 3.6.9.
body = Point("my_measurement").tag("location", "Prague").tag("location", "Tladistad").field("temperature", 25.3) write_api.write(bucket=buck, org=organisation, record=body)
the above works fine, but i want to use json (dictionary) and i also want have multiple tags and fields like below
json_body = [{"measurement": organisation, "tags":{"tag1":"tag1", "tag2": "tag2"}, "fields":{'field1':1, "field2":2}}] write_api.write(bucket=buck, org=organisation, record=json_body)
i get the error below
Traceback (most recent call last): File "initialize.py", line 12, in <module> write_api.write(bucket=buck, org=organisation, record=json_body) File "/home/moeketsi/.local/lib/python3.6/site-packages/influxdb_client/client/write_api.py", line 217, in write final_string = self._serialize(record, write_precision, **kwargs) File "/home/moeketsi/.local/lib/python3.6/site-packages/influxdb_client/client/write_api.py", line 263, in _serialize **kwargs) for item in record]) File "/home/moeketsi/.local/lib/python3.6/site-packages/influxdb_client/client/write_api.py", line 263, in <listcomp> **kwargs) for item in record]) File "/home/moeketsi/.local/lib/python3.6/site-packages/influxdb_client/client/write_api.py", line 253, in _serialize _result = self._serialize(Point.from_dict(record, write_precision=write_precision), File "/home/moeketsi/.local/lib/python3.6/site-packages/influxdb_client/client/write/point.py", line 37, in from_dict point.time(dictionary['time'], write_precision=write_precision) KeyError: 'time'
can you kindly assist, thank you (edited)