Skip to content
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

The _do_call method needs a check for application/zip content #18

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions ultra_rest_client/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,22 @@ def _do_call(self, uri, method, params=None, body=None, retry=True, files=None,
# body = {"errorCode":60001,"errorMessage":"invalid_grant:token not found, expired or invalid"}
if r1.status_code == requests.codes.NO_CONTENT:
return {}
# some endpoints have no content-type header
if 'content-type' not in r1.headers:
r1.headers['content-type'] = 'none'
# if the content-type is text/plain just return the text
if r1.headers['Content-Type'] == 'text/plain':
if r1.headers['content-type'] == 'text/plain':
return r1.text
# Return the bytes. Zone exports produce zip files when done in batch.
if r1.headers['content-type'] == 'application/zip':
return r1.content
json_body = r1.json()
# if this is a background task, add the task id to the body
# if this is a background task, add the task id (or location) to the body
if r1.status_code == requests.codes.ACCEPTED:
json_body['task_id'] = r1.headers['x-task-id']
if 'x-task-id' in r1.headers:
json_body['task_id'] = r1.headers['x-task-id']
if 'location' in r1.headers:
json_body['location'] = r1.headers['location']
if type(json_body) is dict:
if retry and u'errorCode' in json_body and json_body[u'errorCode'] == 60001:
self._refresh()
Expand Down
Loading