File "c:\Users\hp\Desktop\DHAN ALGO\9. Session9- 3rd Live Algo Version 2\3rd live Algo\Dhan_Tradehull_V2.py", line 139, in order_placement orderid = order["data"]["orderId"] KeyError: 'orderId'

Unable to place order
File “c:\Users\hp\Desktop\DHAN ALGO\9. Session9- 3rd Live Algo Version 2\3rd live Algo\Dhan_Tradehull_V2.py”, line 139, in order_placement
orderid = order[“data”][“orderId”]
KeyError: ‘orderId’
please guide

1 Like

@Tradehull_Imran

getting same error… were you able to solve this?

Hi @Jitendra_Singh1 ,

Use the below code to check if orderid is present in it or not:

if "data" in order and "orderId" in order["data"]:
    orderid = order["data"]["orderId"]
else:
    print("Order ID not found in response:", order)