Skip to content
This repository was archived by the owner on Feb 10, 2021. It is now read-only.

Commit 68d41f5

Browse files
author
Aubron Wood
authored
Merge pull request #33 from jmulford-bandwidth/changed-api-response-header
Added application/json hotfix, updated version number of SDK
2 parents 221bc68 + 8ff9107 commit 68d41f5

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

bandwidth/account/client_module.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ def _request(self, method, url, *args, **kwargs):
6868

6969
def _check_response(self, response):
7070
if response.status_code >= 400:
71-
if response.headers.get('content-type') == 'application/json':
71+
if response.headers.get('content-type') is not None and \
72+
response.headers.get('content-type').startswith("application/json"):
7273
data = response.json()
7374
raise BandwidthAccountAPIException(
7475
response.status_code, data['message'], code=data.get('code'))
@@ -81,7 +82,8 @@ def _make_request(self, method, url, *args, **kwargs):
8182
self._check_response(response)
8283
data = None
8384
id = None
84-
if response.headers.get('content-type') == 'application/json':
85+
if response.headers.get('content-type') is not None and \
86+
response.headers.get('content-type').startswith("application/json"):
8587
data = convert_object_to_snake_case(response.json())
8688
location = response.headers.get('location')
8789
if location is not None:

bandwidth/messaging/client_module.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ def _request(self, method, url, *args, **kwargs):
6767

6868
def _check_response(self, response):
6969
if response.status_code >= 400:
70-
if response.headers.get('content-type') == 'application/json':
70+
if response.headers.get('content-type') is not None and \
71+
response.headers.get('content-type').startswith("application/json"):
7172
data = response.json()
7273
raise BandwidthMessageAPIException(
7374
response.status_code, data['message'], code=data.get('code'))
@@ -80,7 +81,8 @@ def _make_request(self, method, url, *args, **kwargs):
8081
self._check_response(response)
8182
data = None
8283
id = None
83-
if response.headers.get('content-type') == 'application/json':
84+
if response.headers.get('content-type') is not None and \
85+
response.headers.get('content-type').startswith("application/json"):
8486
data = convert_object_to_snake_case(response.json())
8587
location = response.headers.get('location')
8688
if location is not None:

bandwidth/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = 'v3.0.1'
1+
__version__ = 'v3.0.2'

bandwidth/voice/client_module.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ def _request(self, method, url, *args, **kwargs):
7676

7777
def _check_response(self, response):
7878
if response.status_code >= 400:
79-
if response.headers.get('content-type') == 'application/json':
79+
if response.headers.get('content-type') is not None and \
80+
response.headers.get('content-type').startswith("application/json"):
8081
data = response.json()
8182
raise BandwidthVoiceAPIException(
8283
response.status_code, data['message'], code=data.get('code'))
@@ -89,7 +90,8 @@ def _make_request(self, method, url, *args, **kwargs):
8990
self._check_response(response)
9091
data = None
9192
id = None
92-
if response.headers.get('content-type') == 'application/json':
93+
if response.headers.get('content-type') is not None and \
94+
response.headers.get('content-type').startswith("application/json"):
9395
data = convert_object_to_snake_case(response.json())
9496
location = response.headers.get('location')
9597
if location is not None:

0 commit comments

Comments
 (0)