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 generated a client to consume an API. One of the endpoints returns an octet-stream of a zipped file with .zip extension. When receiving this file, I get the following error trace. I get that this is to do with encoding, but I have no idea how to make the codegen generate code that works. When I try chardet it says {'encoding': None, 'confidence': 0.0, 'language': None}. When I fetch the report in Postman, I can save the raw response as a zip file and extract a csv file with no issues.
File "/home/user/dev/my_sdk/api_client.py", line 328, in call_api
return self.__call_api(resource_path, method,
File "/home/user/dev/my_sdk/api_client.py", line 156, in __call_api
response_data = self.request(
File "/home/user/dev/my_sdk/api_client.py", line 350, in request
return self.rest_client.GET(url,
File "/home/user/dev/my_sdk/rest.py", line 257, in GET
return self.request("GET", url,
File "/home/user/dev/my_sdk/rest.py", line 226, in request
r.data = r.data.decode('utf8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xaa in position 10: invalid start byte
Use the generated client to request the zip file, and you get the error
Related issues/PRs
Suggest a fix/enhancement
The text was updated successfully, but these errors were encountered:
NA-Dev
changed the title
[JAVA] Error when receiving .zip file octet-stream response from API endpoint
[PYTHON] Error when receiving .zip file octet-stream response from API endpoint
Dec 22, 2023
I think this is a file that needs to be saved without decoding. Can I generate a client that does that, or do I need to set _preload_content to False, and handle it all manually?
Description
I generated a client to consume an API. One of the endpoints returns an octet-stream of a zipped file with .zip extension. When receiving this file, I get the following error trace. I get that this is to do with encoding, but I have no idea how to make the codegen generate code that works. When I try chardet it says {'encoding': None, 'confidence': 0.0, 'language': None}. When I fetch the report in Postman, I can save the raw response as a zip file and extract a csv file with no issues.
Swagger-codegen version
3.0.30
Swagger declaration file content or url
Command line used for generation
java -jar swagger-codegen-cli.jar generate
-i openapi-spec.yaml
-l python
-o generated_code
-c config.json
Steps to reproduce
Use the generated client to request the zip file, and you get the error
Related issues/PRs
Suggest a fix/enhancement
The text was updated successfully, but these errors were encountered: