Method 1:
def get_positions(susertoken, actid): url = base_url +"PositionBook" data = {"uid": "TEST18","actid": actid } payload = {"jData": json.dumps(data),"jKey": susertoken } headers = {'Content-Type': 'application/x-www-form-urlencoded' } response = requests.post(url, headers=headers, data=payload) response_text = response.text print(response_text)
Method 2:
def get_positions(susertoken, actid): url = base_url+"PositionBook" data = {"jData": '{"uid":"TEST18", "actid":"'+ actid +'"}',"jKey": susertoken } payload = "jData="+json.dumps(data) headers = {'Content-Type': 'application/json' } response = requests.request("POST", url, headers=headers, data=payload) response_json = response.json() print(response_json)
API, I am using is here - https://shoonya.com/api-documentation#positions-booklogin is successful and susertoken and actid are correct.