influxdb-client-python icon indicating copy to clipboard operation
influxdb-client-python copied to clipboard

buckets_api.create_bucket() returns ApiException

Open meetaco opened this issue 6 years ago • 2 comments

I called create_bucket() specifying only "bucket_name", and it returned these:

Traceback (most recent call last): File "utils.py", line 422, in influx = InfluxDB(url="[masked]", token=token, org="meetaco_org", bucket="a") File "utils.py", line 355, in init self.buckets_api.create_bucket(bucket_name=self.bucket) File "/usr/local/lib/python3.7/site-packages/influxdb_client/client/bucket_api.py", line 43, in create_bucket return self._buckets_service.post_buckets(post_bucket_request=bucket) File "/usr/local/lib/python3.7/site-packages/influxdb_client/service/buckets_service.py", line 1302, in post_buckets (data) = self.post_buckets_with_http_info(post_bucket_request, **kwargs) # noqa: E501 File "/usr/local/lib/python3.7/site-packages/influxdb_client/service/buckets_service.py", line 1383, in post_buckets_with_http_info collection_formats=collection_formats) File "/usr/local/lib/python3.7/site-packages/influxdb_client/api_client.py", line 339, in call_api _preload_content, _request_timeout) File "/usr/local/lib/python3.7/site-packages/influxdb_client/api_client.py", line 170, in __call_api _request_timeout=_request_timeout) File "/usr/local/lib/python3.7/site-packages/influxdb_client/api_client.py", line 382, in request body=body) File "/usr/local/lib/python3.7/site-packages/influxdb_client/rest.py", line 278, in POST body=body) File "/usr/local/lib/python3.7/site-packages/influxdb_client/rest.py", line 231, 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': 'Sun, 03 May 2020 20:38:06 GMT', 'Content-Length': '97'}) HTTP response body: { "code": "invalid", "message": "failed to unmarshal json: id must have a length of 16 bytes" }

Is this a bug?

meetaco avatar May 03 '20 21:05 meetaco

Hi @meetaco,

It is not bug. It is unclear error message from InfluxDB. You should also specify a org_id for bucket creation. Something like this:

my_bucket = self.buckets_api.create_bucket(bucket_name='bucket_name', org_id=my_org.id)

Regards

bednar avatar May 04 '20 06:05 bednar

@bednar Thank you very much. It worked!

meetaco avatar May 04 '20 06:05 meetaco