You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The call to authorization_api.create_authorization(authorization) should return a newly created token.
Actual behavior
authorization_api.create_authorization(authorization) fails with return code 400
invalid json structure: json: cannot unmarshal object into Go struct field postAuthorizationRequest.orgID of type platform.ID
It appears that in the python tutorial the example method def create_authorization(device_id) -> Authorization: has an outdated or misleading usage of request = authorization_api.create_authorization(authorization)
It should be request = authorization_api.create_authorization(authorization=authorization).
Using purely positional arguments assigns the authorization object to the org_id property of an internally instantiated default Authorization object.
I'm adding some type checks to this area of the code and reviewing the tutorial and similar examples.
Specifications
Code sample to reproduce problem
I followed the Python client tutorial and adapted
create_authorization
to my needs:Expected behavior
The call to
authorization_api.create_authorization(authorization)
should return a newly created token.Actual behavior
authorization_api.create_authorization(authorization)
fails with return code 400invalid json structure: json: cannot unmarshal object into Go struct field postAuthorizationRequest.orgID of type platform.ID
Additional info
Authorization: {'created_at': None,
'description': 'Write permission for device_name to bucket_name.',
'id': None,
'links': None,
'org': None,
'org_id': 'my-org-id',
'permissions': [{'action': 'write',
'resource': {'id': 'my-bucket-id',
'name': None,
'org': None,
'org_id': 'my-org-id',
'type': 'buckets'}}],
'status': 'active',
'token': None,
'updated_at': None,
'user': None,
'user_id': None}
Traceback (most recent call last):
File "C:\Users\EMnify\PycharmProjects\csv2influx\c_to_i\db\device.py", line 25, in create_authorization
return authorization_api.create_authorization(authorization)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
File "C:\Users\EMnify\PycharmProjects\csv2influx.venv\Lib\site-packages\influxdb_client\client\authorizations_api.py", line 30, in create_authorization
return self._authorizations_service.post_authorizations(authorization_post_request=authorization)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\EMnify\PycharmProjects\csv2influx.venv\Lib\site-packages\influxdb_client\service\authorizations_service.py", line 557, in post_authorizations
(data) = self.post_authorizations_with_http_info(authorization_post_request, **kwargs) # noqa: E501
File "C:\Users\EMnify\PycharmProjects\csv2influx.venv\Lib\site-packages\influxdb_client\service\authorizations_service.py", line 579, in post_authorizations_with_http_info
return self.api_client.call_api(
~~~~~~~~~~~~~~~~~~~~~~~~^
'/api/v2/authorizations', 'POST',
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<12 lines>...
collection_formats={},
^^^^^^^^^^^^^^^^^^^^^^
urlopen_kw=kwargs.get('urlopen_kw', None))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\EMnify\PycharmProjects\csv2influx.venv\Lib\site-packages\influxdb_client_sync\api_client.py", line 343, in call_api
return self.__call_api(resource_path, method,
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
path_params, query_params, header_params,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<2 lines>...
_return_http_data_only, collection_formats,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_preload_content, _request_timeout, urlopen_kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\EMnify\PycharmProjects\csv2influx.venv\Lib\site-packages\influxdb_client_sync\api_client.py", line 173, in __call_api
response_data = self.request(
method, url, query_params=query_params, headers=header_params,
post_params=post_params, body=body,
_preload_content=_preload_content,
_request_timeout=_request_timeout, **urlopen_kw)
File "C:\Users\EMnify\PycharmProjects\csv2influx.venv\Lib\site-packages\influxdb_client_sync\api_client.py", line 388, in request
return self.rest_client.POST(url,
~~~~~~~~~~~~~~~~~~~~~^^^^^
query_params=query_params,
^^^^^^^^^^^^^^^^^^^^^^^^^^
...<4 lines>...
body=body,
^^^^^^^^^^
**urlopen_kw)
^^^^^^^^^^^^^
File "C:\Users\EMnify\PycharmProjects\csv2influx.venv\Lib\site-packages\influxdb_client_sync\rest.py", line 311, in POST
return self.request("POST", url,
~~~~~~~~~~~~^^^^^^^^^^^^^
headers=headers,
^^^^^^^^^^^^^^^^
...<4 lines>...
body=body,
^^^^^^^^^^
**urlopen_kw)
^^^^^^^^^^^^^
File "C:\Users\EMnify\PycharmProjects\csv2influx.venv\Lib\site-packages\influxdb_client_sync\rest.py", line 261, 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-Influxdb-Build': 'OSS', 'X-Influxdb-Version': 'v2.7.10', 'X-Platform-Error-Code': 'invalid', 'Date': 'Tue, 26 Nov 2024 14:45:22 GMT', 'Content-Length': '163'})
HTTP response body: {
"code": "invalid",
"message": "invalid json structure: json: cannot unmarshal object into Go struct field postAuthorizationRequest.orgID of type platform.ID"
}
From the debugger:
body = {'orgID': {'description': 'Write permission for device_name to bucket_name.', 'orgID': 'my-org-id', 'permissions': [{'action': 'write', 'resource': {'id': 'my-bucket-id', 'orgID': 'my-org-id', 'type': 'buckets'}}], 'status': 'active'}, 'status': 'active'}
The text was updated successfully, but these errors were encountered: