Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
I'm trying to add a logo to a brand via the API using the SDK, but I'm getting errors:
qlik.brands.create(name=client_tenant["client_name"],logo="temp_files/logo.png")
It's bringing me back the error:
qlik_sdk/utils.py", line 7, in get_mime_type
first_bytes = buffer.peek()
AttributeError: 'str' object has no attribute 'peek'
When I create the Brand but omit the logo it works. 've tried adding the logo separately using:
files_dict = {"file":"temp_files/Logo.png"}
response = qlik_oauth_connection.client.rest(
path=f"/brands/{brand_id}/files/logo",
method="POST",
params={},
data=None,
files=files_dict
)
I get an error 400 Client Error: Bad Request for url:
Imagine it's something simple, although I'm stumped at the moment. Any help would be appreciated
Hi @richardpearce60 ,
I don't know if this can help you troubleshoot this, but when using the Qlik-cli, this is they payload that is sent to the REST endpoint
POST https://TENANT.REGION.qlikcloud.com/api/v1/brands
* Establishing connection to: TENANT.REGION.qlikcloud.com:443
* TLS Handshake started
* TLS Handshake done (352ms), version: TLS v1.3
* Connection established (816ms)
> Host: TENANT.REGION.qlikcloud.com
> User-Agent: qlik-cli/2.26.0 (darwin)
> Transfer-Encoding: chunked
> Authorization: Bearer **omitted**
> Content-Type: multipart/form-data; boundary=6143ff2ea36c74340000a46387a39faec2ee3ea1989299a6302a83095d11
> Referer: https://TENANT.REGION.qlikcloud.com
> Accept-Encoding: gzip
PAYLOAD (MULTIPART):
------
> Content-Disposition: form-data; name="logo"; filename="FILEPATH/logo.png"
> Content-Type: image/png
PART:
image data: 63215 bytes
------
> Content-Disposition: form-data; name="name"
PART:
BRANDNAME
------
-------
The cli command I used is:
qlik brand create -v --name BRANDNAME --file-logo FILEPATH/logo.png
Thanks @Daniele_Purrone ..
We have been able to get it to work in Postmaster. I wasn't sure if CLI and PostMaster were doing something in the background with the binary file?
I've been googling and tried many different combinations, using the file open within the dictionary too {"Logo": open("temp_files/logo.png", "rb")}, but nothing seems to work.
We have 100 tenants, so we want to automate ...
@DaveChannon Hi Dave, I was wondering if you knew how to resolve this?