Write data with the influxdb API

Hi everyone,

I want to use the API to write data, and I refer to reading documents for the syntax line protocol as the following:

<measurement>[,<tag_key>=<tag_value>[,<tag_key>=<tag_value>]] <field_key>=<field_value>[,<field_key>=<field_value>] [<timestamp>]

this format data works fine

testing,enable=true,id_project=1 last=23

But if I replace the field_key with strings, then I get the following error:

testing,enable=true,id_project=1 last="this is a test"

HTTP/1.1 500 Internal Server Error
Content-Type: 
Request-Id: 
X-Influxdb-Build: ENT
X-Influxdb-Error: write failed: partial write: field type conflict: input field "last" on measurement "push_mirror" is type string, already exists as type float dropped=1
X-Influxdb-Version: 1.9.3-c1.9.3
X-Request-Id: 
Date: Sat, 07 May 2022 16:18:24 GMT
Content-Length: 169

{"error":"write failed: partial write: field type conflict: input field \"last\" on measurement \"push_mirror\" is type string, already exists as type float dropped=1"}

where am I going wrong with syntax?
Thanks in advance!

Sounds like data type definition. What is data type for last defined as?

I found the issue, as @yosiasz said that this is an issue about data type definition when I defined and stored the field value as an interger first, so that’s reason I got an error above.

Thanks for your comment which leads me to that thought.

1 Like