Closed nonstdout closed 2 years ago
Submitted PR #26
@nonstdout
Sorry for the delay.
There was an issue with the documentation for download_a_file_by_fileid, the return type is urllib3.response.HTTPResponse rather than MyDict.
The Content-Type of the DNA Center API File is usually application/octet-stream rather than application/json.
namespaces = api.file.get_list_of_available_namespaces().response
namespace = namespaces[0]
files = api.file.get_list_of_files(namespace).response
file_ids = [i.id for i in files]
file_id = file_ids[0]
response1 = api.file.download_a_file_by_fileid(file_id, save_file=False)
print("save_file=False", len(response1.data) > 0, len(response1.data)) # save_file=False True 13550 (for example)
response2 = api.file.download_a_file_by_fileid(file_id, save_file=True)
# save_file=True False 0 # Is zero as it has already read the data and wrote it to a file
print("save_file=True", len(response2.data) > 0, len(response2.data))
# response1.__dict__ # If you still want a dict
Just in case, response1.data are bytes, hopefully, you can convert that to what you need.
Hi,
I believe the method
file.download_a_file_by_fileid(fileid)
is not working correctly. It works correctly when thesave_file
flag is set toTrue
but doesn't return the expected json response when set to defaultFalse
I will be submitting a PR that fixes this issue.
Cheers