Skip to content

Commit

Permalink
Fixes ability to download PDFs by setting the accept header.
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanlister committed Jun 10, 2015
1 parent 5eaf4ed commit ae2dc3a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion xero/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .api import Xero

__version__ = "0.7.0-alpha1"
__version__ = "0.7.0-alpha2"

9 changes: 8 additions & 1 deletion xero/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,15 @@ def wrapper(*args, **kwargs):

if headers is None:
headers = {}
headers['Accept'] = 'application/json'

# Use the JSON API by default, but remember we might request a PDF (application/pdf)
# so don't force the Accept header.
if 'Accept' not in headers:
headers['Accept'] = 'application/json'

# Set a user-agent so Xero knows the traffic is coming from pyxero
headers['User-Agent'] = 'pyxero/%s ' % VERSION + requests.utils.default_user_agent()

response = getattr(requests, method)(
uri, data=body, headers=headers, auth=self.credentials.oauth,
params=params, cert=cert, timeout=timeout)
Expand Down

0 comments on commit ae2dc3a

Please sign in to comment.