Getting Blank Responses on placing orders
-
I am getting blank bytes as a response when I place an order.
import http.client import mimetypes import json conn = http.client.HTTPSConnection( "apiconnect.angelbroking.com" ) payload = "{\n\"clientcode\":\"ccode\",\n\"password\":\"password\"\n}" headers = { 'Content-Type': 'application/json', 'Accept': 'application/json', 'X-UserType': 'USER', 'X-SourceID': 'WEB', 'X-ClientLocalIP': 'localip', 'X-ClientPublicIP': 'publicip', 'X-MACAddress': 'macadress', 'X-PrivateKey': 'apikey' } conn.request( "POST", "/rest/auth/angelbroking/user/v1/loginByPassword", payload, headers) import io res = conn.getresponse() data = res.read() d= data.replace(b"'", b'"') s = json.load(io.BytesIO(d)) tok = s['data']['jwtToken'] print(tok) lok = "Bearer " + str(tok) print(lok) payload = "{\n \"exchange\": \"NSE\",\n \"tradingsymbol\": \"SBIN-EQ\",\n \"quantity\": 10,\n \"disclosedquantity\": 10,\n \"transactiontype\": \"BUY\",\n \"ordertype\": \"LIMIT\",\n \"variety\": \"STOPLOSS\",\n \"producttype\": \"AMO_DELIVERY\",\n \"price\": \"380.30\"\n}" headers = { 'Authorization': lok, 'Content-Type': 'application/json', 'Accept': 'application/json', 'X-UserType': 'USER', 'X-SourceID': 'WEB', 'X-ClientLocalIP': 'localip', 'X-ClientPublicIP': 'publicip', 'X-MACAddress': 'macad', 'X-PrivateKey': 'api ' } cont = http.client.HTTPSConnection( "apiconnect.angelbroking.com" ) cont.request("POST","/rest/secure/angelbroking/order/v1/placeOrder",payload,headers) rese = cont.getresponse() dataf = rese.read() print(dataf)
here is my code, some sensetive parts are replaced by generic terms
-
hi @vishalbordia kindly provide us with your contact details to assist you.
-
@djdenish it dies not work
-
Copy original code from API docs, then put client Id, password and API key in that code and then check.