Skip to content

Commit a037815

Browse files
committed
fix(json): convert json to string for dict types
1 parent 7eb7e88 commit a037815

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

ibm_cloud_sdk_core/base_service.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def __init__(self,
4444
"""
4545
:attr str url: The url for service api calls
4646
:attr Authenticator authenticator: The authenticator for authentication
47-
:attr bool disable_ssl_verification: enables/ disabled ssl verification
47+
:attr bool disable_ssl_verification: enables/ disables ssl verification
4848
:attr str display_name the name used for mapping services in environment file
4949
"""
5050
self.url = url
@@ -179,9 +179,13 @@ def prepare_request(self, method, url, headers=None,
179179
params = cleanup_values(params)
180180
request['params'] = params
181181

182-
data = remove_null_values(data)
183182
if sys.version_info >= (3, 0) and isinstance(data, str):
184183
data = data.encode('utf-8')
184+
185+
if data and isinstance(data, dict):
186+
data = remove_null_values(data)
187+
headers.update({'content-type': 'application/json'})
188+
data = json_import.dumps(data)
185189
request['data'] = data
186190

187191
if self.authenticator:

0 commit comments

Comments
 (0)