Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error While Running the Code
Message
From
21/02/2023 13:56:29
 
 
To
21/02/2023 13:34:59
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01686245
Message ID:
01686247
Views:
72
Likes (1)
Harsh,

Open the URL non-asynchronously.
loHttp.open("POST", lcUrl, .F.)
You may also consider using a more recent and more robust version of the XML HTTP library:
loHttp = CREATEOBJECT("MSXML2.ServerXMLHTTP.6.0")
>Respected Experts
>
>I am getting the following error while executing the Code to call an API for Placing an order with Zerodha Brokrage
>
>OLE IDespatch Exception code 0 from msxml3.dll. The Data Necessary to complete this operation is not yet availalble. Can anyone Guide , how to resolve ?
>
>LOCAL loHttp, lcUrl, lcApiKey, lcAccessToken, lcSymbol, lnQty, lnPrice, lcExchange, lcOrderType, lcProductType, lcVariety, lcResponse
>
>* Replace with your API Key
>lcApiKey = "jqcz8jsxj0mblwwl"
>
>* Replace with your API Access Token
>lcAccessToken = "7p2thd5jugfeuh9q9h4n5d9rt8716q3k"
>
>* Replace with the symbol you want to trade
>lcSymbol = "RELIANCE"
>
>* Replace with the quantity you want to trade
>lnQty = 1
>
>* Replace with the price at which you want to place the order
>lnPrice = 1000
>
>* Replace with the exchange on which you want to trade (NSE or BSE)
>lcExchange = "NSE"
>
>* Replace with the order type (LIMIT, MARKET, SL, SLM)
>lcOrderType = "LIMIT"
>
>* Replace with the product type (CNC, MIS, NRML)
>lcProductType = "MIS"
>
>* Replace with the order variety (regular, amo, bo, co)
>lcVariety = "regular"
>
>* Construct the API URL
>lcUrl = "https://api.kite.trade/orders/regular"
>
>* Create an HTTP object
>loHttp = CREATEOBJECT("MSXML2.XMLHTTP")
>
>* Set the request method and URL
>loHttp.open("POST", lcUrl, .T.)
>
>* Set the request headers
>
>loHttp.setRequestHeader("X-Kite-Version", "3")
>
>loHttp.setRequestHeader("Authorization", "Bearer " + lcAccessToken)
>
>loHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
>
>* Set the request body
>lcBody = "tradingsymbol=" + lcSymbol + "&quantity"+"=" + TRANSFORM(lnQty) + "&price"+ "=" + TRANSFORM(lnPrice) + ;
>"&exchange"+ "=" + lcExchange + "&order_type"+ "=" + lcOrderType + "&product"+ "=" + lcProductType + "&variety"+ "=" + lcVariety
>
>* Send the request and get the response
>loHttp.send(lcBody)
>lcResponse = loHttp.responseText
>
>* Print the response
>? lcResponse
----------------------------------
António Tavares Lopes
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform