Placing order using tokens
-
Dear admin,
Once we generate a session, how do we place order using just tokens?
Right now I am doing this:
client_smartApi = SmartConnect(api_key = client_api_key) login = client_smartApi.generateSession("Client_id","Client_password") orderId=client_smartApi.placeOrder(orderparams) print("OrderId :"+str(orderId)) #obtain the required tokens access_token = client_smartApi.access_token refreshToken = login['data']['refreshToken'] jwtToken = login['data']['jwtToken']
The order is successfully placed here.
As you can see, while placing the order I generateSession for the client using the client ID and the client password.However, how do we generate a session initially and then use the tokens to place the orders at a later point in time?
I tried doing this -
client_smartApi = SmartConnect(api_key = clien_api_key) client_smartApi.setAccessToken(access_token ) client_smartApi.setRefreshToken(refreshToken ) orderId=client_smartApi.placeOrder(orderparams)
This throws an error as follows:
..........\lib\site-packages\smartapi\smartConnect.py in placeOrder(self, orderparams) 288 del(params[k]) 289 --> 290 orderResponse= self._postRequest("api.order.place", params)['data']['orderid'] 291 292 return orderResponse TypeError: string indices must be integers
Could you please guide me with this?
Thank you
-
Any updates on this?
-
@admin
My personal client ID is B133022 -
HI @Bharath-Raj-M Post your client id here.
-
@admin
I could not find any documentation regarding this.Could you please give a step by step instruction on how it is supposed to be done?
-
HI @Bharath-Raj-M I you can use the pubhlisher API to do this.
-
Dear @admin, it's been a while since I posted this, could you review and help us out ?
Regards,
Bharath