in my code i given header value perfact all other order related code are working excpeted when i place order kindly sovle it
elseif Request.QueryString("out") = "0" then
data = "exchange=NFO&tradingsymbol=NIFTY1991911200CE&transaction_type=SELL&order_type=MARKET&price=64.0000m&quantity=75&product=NRML&variety=regular&validity=DAY&trigger_price=0"
Function UrlReturnVal(Url,Method,PostData,HeadReq)
Dim httpRequest, postResponse
Set httpRequest = Server.CreateObject("MSXML2.ServerXMLHTTP") httpRequest.Open Method, Url, False
if HeadReq="Yes" then httpRequest.SetRequestHeader "X-Kite-Version", "3" httpRequest.SetRequestHeader "Authorization", "token zfu63d25sfgjhlx4123lhi:bq8F9HaVFebKuTbHSIJsD3h7crFJ985095asY4PE" end if
if Method = "POST" Then httpRequest.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded" httpRequest.Send PostData else httpRequest.Send end if
postResponse = httpRequest.ResponseText
UrlReturnVal= postResponse
End Function
output
{"status":"error","message":"Invalid `api_key` or `access_token`.","data":null,"error_type":"InputException"}
The 64.0000m is a .NET notation, api doesn't understand this.
Another thing is Zerodha doesn't allow market orders for options. You need to place a limit order with the LTP to fire market order.
data = "tradingsymbol=ACC&exchange=NSE&transaction_type=BUY&order_type=LIMIT&quantity=1&product=NRML&validity=DAY&price=64.23&variety=regular"
UrlPrint=UrlReturnVal("https://api.kite.trade/orders/regular/?" & data,"POST","data","Yes")
{"status":"error","message":"Invalid `api_key` or `access_token`.","data":null,"error_type":"InputException"}
httpRequest.SetRequestHeader "X-Kite-Version", "3"
httpRequest.SetRequestHeader "Authorization", "token zfu63d25jhlx4lhi:n61aeURzB6307D471WHQBpMKwrr3Lyh0"
error
{"status":"error","message":"Invalid `api_key` or `access_token`.","data":null,"error_type":"InputException"}
out=0
httpRequest.SetRequestHeader "X-Kite-Version", "3"
httpRequest.SetRequestHeader "Authorization", "token zfu63d25jhlx4lhi:n61aeURzB6307D471WHQBpMKwrr3Lyh0"
error
{"status":"error","message":"Invalid `api_key` or `access_token`.","data":null,"error_type":"InputException"}
out=0
expect buy and sell order all other working
Your are sending wrong authorization header.
It should be
ApiKey = "your-api-key"
Token = "your-access-token"
httpRequest.SetRequestHeader "Authorization", "token " & ApiKey & ":" & Token
my present token is n61aeURzB6307D471WHQBpMKwrr3Lyh0
kindly solve it
httpRequest.SetRequestHeader "X-Kite-Version", "3"
httpRequest.SetRequestHeader "Authorization","zfu63d25jhlx4lhi:n61aeURzB6307D471WHQBpMKwrr3Lyh0"
Note- You are not supposed post your tokens here... i just edited your codes and posted it..
httpRequest.SetRequestHeader "X-Kite-Version", "3"
httpRequest.SetRequestHeader "Authorization","zfu63d25jhlx4lhi:n61aeURzB6307D471WHQBpMKwrr3Lyh0"