Skip to content

Commit ae2dc3a

Browse files
committed
Fixes ability to download PDFs by setting the accept header.
1 parent 5eaf4ed commit ae2dc3a

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

xero/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from .api import Xero
22

3-
__version__ = "0.7.0-alpha1"
3+
__version__ = "0.7.0-alpha2"
44

xero/manager.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,15 @@ def wrapper(*args, **kwargs):
163163

164164
if headers is None:
165165
headers = {}
166-
headers['Accept'] = 'application/json'
166+
167+
# Use the JSON API by default, but remember we might request a PDF (application/pdf)
168+
# so don't force the Accept header.
169+
if 'Accept' not in headers:
170+
headers['Accept'] = 'application/json'
171+
172+
# Set a user-agent so Xero knows the traffic is coming from pyxero
167173
headers['User-Agent'] = 'pyxero/%s ' % VERSION + requests.utils.default_user_agent()
174+
168175
response = getattr(requests, method)(
169176
uri, data=body, headers=headers, auth=self.credentials.oauth,
170177
params=params, cert=cert, timeout=timeout)

0 commit comments

Comments
 (0)