obj.getMarginApi(params) gives these error --
obj.getMarginApi(params)
JSONDecodeError Traceback (most recent call last)
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\SmartApi\smartConnect.py:231, in SmartConnect._request(self, route, method, parameters)
229 try:
230 #print("RAW RESPONSE:", r.content)
--> 231 data = json.loads(r.content.decode("utf8"))
234 except ValueError:
File ~\AppData\Local\Programs\Python\Python312\Lib\json_init_.py:346, in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
343 if (cls is None and object_hook is None and
344 parse_int is None and parse_float is None and
345 parse_constant is None and object_pairs_hook is None and not kw):
--> 346 return _default_decoder.decode(s)
347 if cls is None:
File ~\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py:337, in JSONDecoder.decode(self, s, _w)
333 """Return the Python representation of s (a str instance
334 containing a JSON document).
335
336 """
--> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
338 end = _w(s, end).end()
File ~\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py:355, in JSONDecoder.raw_decode(self, s, idx)
354 except StopIteration as err:
--> 355 raise JSONDecodeError("Expecting value", s, err.value) from None
356 return obj, end
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
DataException Traceback (most recent call last)
Cell In[40], line 1
----> 1 obj.getMarginApi(params)
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\SmartApi\smartConnect.py:528, in SmartConnect.getMarginApi(self, params)
527 def getMarginApi(self,params):
--> 528 marginApiResult=self._postRequest("api.margin.api",params)
529 return marginApiResult
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\SmartApi\smartConnect.py:265, in SmartConnect._postRequest(self, route, params)
263 def _postRequest(self, route, params=None):
264 """Alias for sending a POST request."""
--> 265 return self._request(route, "POST", params)
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\SmartApi\smartConnect.py:235, in SmartConnect._request(self, route, method, parameters)
231 data = json.loads(r.content.decode("utf8"))
234 except ValueError:
--> 235 raise ex.DataException("Couldn't parse the JSON response received from the server: {content}".format(
236 content=r.content))
238 # api error
239 if data.get("error_type"):
240 # Call session hook if its registered and TokenException is raised
DataException: Couldn't parse the JSON response received from the server: b''