Why is Zerodha throwing Invalid params error in GTT?

surbhigoel
I am trying to place GTT order in Python without KiteConnect as I wanted to try once before purchasing but constantly getting 'Invalid order params' error. Please tell what I am doing wrong as GET request is working perfectly but not POST.

def place_gtt_order(self):
orders = [{
"exchange": "NSE",
"tradingsymbol": "INFY",
"transaction_type": "SELL",
"quantity": 1,
"order_type": "LIMIT",
"product": "CNC",
"price": 702.5
}]
params = {}
params["orders"] = orders
params["type"] = 'single'
params["condition"] = {
"exchange": 'NSE',
"tradingsymbol": 'INFY',
"trigger_values": [702.0],
"last_price": self.ltp("NSE:" + 'INFY')
}

response = self.session.post("https://api.kite.trade/gtt/triggers",
data=params, headers=self.headers).json()
return response
Response comes out to be

{'status': 'error', 'message': 'Invalid order params.', 'data': None, 'error_type': 'InputException'}

TIA
Tagged:
  • rakeshr
    'message': 'Invalid order params.', 'data': None, 'error_type': 'InputException'
    headers=self.headers
    Can you paste here the header assignment?
    Make sure, to add "Content-Type": "application/x-www-form-urlencoded" in the headers.
  • surbhigoel
    @rakeshr these are the headers I am using but still getting error
    self.headers = {"Authorization": f"enctoken {enctoken}",
    "X-Kite-Version": "3",
    "Content-Type": "application/x-www-form-urlencoded"}
  • rakeshr
    "Authorization": f"enctoken {enctoken}"
    You don't seem to be using kiteconnect API. Go through the documentation here.
  • surbhigoel
    Yes, I told in the question that it's without using KiteConnect as I wanted to try once before purchasing. Can you help in this case? TIA
  • sujith
    Kite Connect doesn't have sandbox environment. You need to subscribe to use Kite Connect APIs.
Sign In or Register to comment.