zerodha / pykiteconnect

The official Python client library for the Kite Connect trading APIs
MIT License
981 stars 469 forks source link

raise exception for status=error but no error_type in response #73

Closed shailysangwan closed 3 years ago

shailysangwan commented 4 years ago

Request: curl "https://api.kite.trade/mf/orders" -H "X-Kite-Version: 3" -H "Authorization: token <api_key>:<access_token>" -d "tradingsymbol=INF174K01LSS" -d "transaction_type=BUY" -d "amount=1000" Response: {"status":"error","message":"Invalid `isin`","data":{}}

I think it would be great if there were an error_type with this response so that an exception is raised in case of an invalid payload with some information with what went wrong. I also noticed similar behaviour with /mf/sips and a few other apis. This should hopefully help work around that.

vividvilla commented 3 years ago

This seems like a valid issue, will merge this and release it with v3.9.x since it could be breaking change for existing users.