-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't download the report after using 'RetrieveExport' function #114
Comments
The easiest hacky "fix" would be to check python3-krakenex/krakenex/api.py Line 140 in d88fc51
I am generally against this approach, as this would mean that the same function returns different-type values depending on the arguments passed to it, while none of the arguments pertain to content-type or de-serialisation. Another hacky workaround would be to add an argument specifically stating not to expect JSON... Which runs into the complication of "what if the remote responds with JSON, e.g. due to error". Finally, to maintain a uniform interface, {
'error': [],
'result': <SOME-HACKY-WAY-TO-PRESENT-BINARY-RESPONSE>
} |
Meanwhile, perhaps you could try the following workaround, specifically so you can move on: # Trying to retrieve the report: response is binary if successful
from json import JSONDecodeError
try:
maybe_error = k.query_private('RetrieveExport', {'id': report_id})
except JSONDecodeError:
export_bytes = k.response.content
else:
response_error = maybe_error From
|
Hi, Got this piece of code from Kraken support that is suggesting to modify the "_query" function.
Didn't manage to test it already as the 'AddExport' function throw me the following error I will update you when fixed but it seems that the suggested fix would be worth adding to the master. |
The solution is wholly unacceptable to me. It writes to file on-disk as a side-effect, returns a plain string instead of a JSON-derived If that works for you - wonderful, but please don't submit a PR with it. :) I'll think of something else when I get the time. |
I would like to bring this issue back up. I have run into the same problem as the original submission. |
@Exodus4400 Have you tried the workaround suggested in #114 (comment)? |
I've added an example based on OP's description in Sorry all for being so stubborn about this, but as far as I see (Something to keep in mind: some workarounds for this issue are blockers for issue #103.) |
Versions
What are you trying to achieve?
I'm trying to create and open a report using 'AddExport' and 'RetrieveExport' functions.
Ideally, I would like to be able to retrieve data from the report within my python script to do some custom reporting but downloading it would be acceptable as well.
What do you expect to happen?
Etiher download the report or retrieve the data that it contains.
What happens instead?
Got the following error...
In kraken API docs it says:
"Result: binary zip archive containing the report
Note: If content-type isn't application/json, text, or html, the binary report will be streamed back. If it is one of those types you can expect an error in the response."
Not sure to understand what it means... but as this api calls returns something else (a binary zip file) than usual, maybe the 'query_private' function isn't appropriate?
Thanks for your help and for this amazing work!!
The text was updated successfully, but these errors were encountered: