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
I am trying to use the namespaceApi > create_file, using the example provided in documentation, to create a pdf file.
The operation fails with TypeError: Object of type 'bytes' is not JSON serializable (stack trace below).
From my investigations it seems that the Content-Type supplied as parameter to create_file gets overridden in create_file_with_http_info(file_path, x_isi_ifs_target_type, file_contents, **kwargs) to application/json.
Am I missing something ?
Expected result:
The file should be created with the provided content.
** Environment**
python 3.6
rhel 7.x
isilon 8.0.0.6
sample code
import isi_sdk_8_0
import base64
# configure client
configuration = isi_sdk_8_0.Configuration()
configuration.host = 'https://isilon:8080'
configuration.username = 'root'
configuration.password = 'bla'
configuration.verify_ssl = False
## create api instance
api_instance = isi_sdk_8_0.NamespaceApi(isi_sdk_8_0.ApiClient(configuration))
## upload /tmp/sample.txt
file_path = 'esign-ap/sample.txt' # str | File path relative to /.
x_isi_ifs_target_type = 'object' # str | Specifies the resource type. (default to object)
x_isi_ifs_access_control = '0600' # str | Specifies a pre-defined ACL value or POSIX mode with a string in octal string format. (optional) (default to 0600)
content_encoding = None # str | Specifies the content encoding that was applied to the object content, so that decoding can be applied when retrieving the content. (optional)
content_type = 'binary/octet-stream' # str | Specifies a standard MIME-type description of the content format. (optional) (default to binary/octet-stream)
overwrite = True # bool | Deletes and replaces the existing user attributes and ACLs of the directory with user-specified attributes and ACLS from the header, when set to true. (optional)
file_contents = 'file_contents_example' # str | The contents of the file object.
local_file_path = '/tmp/sample.pdf'
with open(local_file_path, 'rb') as f:
file_contents = f.read()
api_response = api_instance.create_file(file_path, x_isi_ifs_target_type, file_contents, x_isi_ifs_access_control=x_isi_ifs_access_control, overwrite=overwrite)
Stack trace
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/app-root/lib/python3.6/site-packages/isi_sdk_8_0/api/namespace_api.py", line 529, in create_file
(data) = self.create_file_with_http_info(file_path, x_isi_ifs_target_type, file_contents, **kwargs) # noqa: E501
File "/opt/app-root/lib/python3.6/site-packages/isi_sdk_8_0/api/namespace_api.py", line 633, in create_file_with_http_info
collection_formats=collection_formats)
File "/opt/app-root/lib/python3.6/site-packages/isi_sdk_8_0/api_client.py", line 346, in call_api
_preload_content, _request_timeout)
File "/opt/app-root/lib/python3.6/site-packages/isi_sdk_8_0/api_client.py", line 177, in __call_api
_request_timeout=_request_timeout)
File "/opt/app-root/lib/python3.6/site-packages/isi_sdk_8_0/api_client.py", line 397, in request
body=body)
File "/opt/app-root/lib/python3.6/site-packages/isi_sdk_8_0/rest.py", line 369, in PUT
body=body)
File "/opt/app-root/lib/python3.6/site-packages/isi_sdk_8_0/rest.py", line 164, in request
request_body = json.dumps(body)
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/json/encoder.py", line 180, in default
o.__class__.__name__)
TypeError: Object of type 'bytes' is not JSON serializable
The text was updated successfully, but these errors were encountered:
Hi,
I am trying to use the
namespaceApi > create_file
, using the example provided in documentation, to create a pdf file.The operation fails with
TypeError: Object of type 'bytes' is not JSON serializable
(stack trace below).From my investigations it seems that the Content-Type supplied as parameter to
create_file
gets overridden increate_file_with_http_info(file_path, x_isi_ifs_target_type, file_contents, **kwargs)
toapplication/json
.Am I missing something ?
Expected result:
The file should be created with the provided content.
** Environment**
sample code
Stack trace
The text was updated successfully, but these errors were encountered: