Using old InfluxDB Java client with InfluxDB 2.7?

A lot of our codebase is using org.influxdb:influxdb-java:2.15 (which is for influxDB 1.x).
According to the github page, it should also work with the backwards compatibility API of influxDB 2.7.

However, I can’t get it to work. Connection seems to work (at least it doesn’t throw an error), but as soon as I send a query I get “Unautherized” back.
I tried using my username together with the password, as well as together with an API token. Both times same result.
I have also tried sending a request just by curl. Same result. I can’t authenticate with the backwards-compatibility endpoint. Do I have to activate it or open it or something (This is an OSS installation, btw, not cloud).

I have checked and confirmed that the DBRPS mapping exists:

			"id": "d7145021f81a9a1c",
			"database": "yellow-bmetry",
			"retention_policy": "autogen",
			"default": true,
			"virtual": true,
			"orgID": "ba9404e4f918544c",
			"bucketID": "d7145021f81a9a1c"

But still, if I curl the following query, I can’t get in, and neither can I get in with the Java client:

curl --get "http://localhost:8086/query" \
  --user "jedidia":"********" \
  --data-urlencode "db=yellow-bmetry" \
  --data-urlencode "q=SELECT * FROM bmetry-image-info"

Can anybody help me get this to work?

I’ve never used this, but this page implies there is a separate authorization layer for the v1 compatibility endpoints.

If this was the cause please reply below so it can help others

1 Like

Huh, yes, now I could get it to work. I think it would be a good idea to feature a link to this rather prominently on this page: InfluxDB 1.x compatibility API | InfluxDB OSS v2 Documentation

Now that I know what I was looking for I found it mentioned somewhere further down, and only in the context of using password/username scheme. The page really gives the impression that it should be possible to use it with normal tokens, but that has not been my experience.

Also a bit of a pity that it only can be set up in influx-cli and not through the web-api. I find extremely clunky to need to provision the new influx-cli to servers running the database, and running commands on it through puppet to set up the database…

Yeh agree it’s not ideal, there’s quite a bit of history behind it though, in short influxdb v2 had a false start, and reverted back to using TSM engine underneath (similar I believe to v1 ). That appears to have lead to other challenges in keeping things uniform (and reintroducing? ) the compatibility api layer to help build a bridge for v1 users.

Fast forward to now, and v3 is (hopefully ) just around the corner, and appears to have kept the best bits from v1, and built those on top of other Apache foundations to deliver what v2 originally intended to do.

Such is life sometimes , progress isn’t always linear or forward.

1 Like