Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Set XML Accept header when fetching tabular data #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 7 additions & 1 deletion PyBambooHR/PyBambooHR.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,13 @@ def get_tabular_data(self, table_name, employee_id='all'):
the values of the table's fields for a particular date, which is stored by key 'date' in the dictionary.
"""
url = self.base_url + 'employees/{}/tables/{}'.format(employee_id, table_name)
r = requests.get(url, timeout=self.timeout, headers=self.headers, auth=(self.api_key, ''))

# The default initialization for instances of this class sets the Accept header to application/json. The
# transform_tabular_data utility function that is used to parse the response expects XML content.
headers=self.headers.copy()
headers['Accept'] = 'application/xml'

r = requests.get(url, timeout=self.timeout, headers=headers, auth=(self.api_key, ''))
r.raise_for_status()

return utils.transform_tabular_data(r.content)
Expand Down