I’m trying to run a simple query to read the measurements (tables) using PHP code V1 API using curl,
but I always get an error message , we have a “V3 Cloud Serverless Version” license.
Is this possible, or do I need the “V3 Cloud Dedicated” license?
I used “user” as the USER.
I used the token as the PWD.
I used the bucketname as the DB.
<?php
$sql = "SHOW MEASUREMENTS";
//$sql = "SELECT * FROM \"Volumenmessung\"";
$url = "https://eu-central-1-1.aws.cloud2.influxdata.com/query?" . http_build_query (["db" => "UPCYCLE0_TEST",'q' => $sql]);
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_USERPWD, "$username:$token");
$response = curl_exec($ch);
$lastRequestInfo = curl_getinfo($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
?>
In both cases, I get the error message “database not found: UPCYCLE0_TEST”.
This is the curl request from the github PHP Client V1 project.
I simply want to read the tables (MEASUREMENTS) or all entries from the measurement (volume measurement).
Whats wrong?
lg
Gerald Hoch
I’ve found the problem, if you want to make a query with the API V1 on a V3 you have to create a retention policy first.
I’ve done it with the CLI.
-
first you create a config and set it active
.\influx.exe config create
–config-name “YOUR_CONFIGNAME”
–host-url https://eu-central-1-1.aws.cloud2.influxdata.com
–org <YOUR_ORGNAME>
–token <YOUR_TOKEN>
–active
-
list the buckets
.\influx.exe bucket list
-
create retention policy on the bucket with a DB-name
.\influx.exe v1 dbrp create
–bucket-id <YOUR_BUCKET_ID>
–db <YOUR_DBNAME>
–rp autogen
–default
all works fine now.
1 Like