string indices must be integers


  • Re: Error while placing order

    Hey whenever I place my orders, the orders usually get executed, however sometimes, I get the error:
    "string indices must be integers"

    Here is a gist of my code:

    client_smartApi=SmartConnect(api_key='api_key')
    login = client_smartApi.generateSession('Client_id','password')
    try:
    orderparams = {
    "variety": "NORMAL",
    "tradingsymbol": tradingsymbol,
    "symboltoken": symbol_token,
    "transactiontype": transactiontype,
    "exchange": symbolexchange,
    "ordertype": "MARKET",
    "producttype": "CARRYFORWARD",
    "duration": "DAY",
    "quantity": quantity
    }
    orderId=client_smartApi.placeOrder(orderparams)
    except Exception as e:
    print(e)


  • Hello Guys,

    the solution is to reset token, as below.

    try:
    data = self.obj.generateSession(client_id,Password)
    return data['data']['refreshToken']
    except Exception as e:
    print ("Login failed: {}".format(e))


  • @Bharath-Raj-M Did you get this problem solved? I am facing the same issue and it is very intermittent.
    If this is solved. can you please let me know how?


  • HI @Bharath-Raj-M Please go through the below req, You have not passed few parameter as string.
    {
    "variety":"NORMAL",
    "tradingsymbol":"SBIN-EQ",
    "symboltoken":"3045",
    "transactiontype":"BUY",
    "exchange":"NSE",
    "ordertype":"MARKET",
    "producttype":"INTRADAY",
    "duration":"DAY",
    "price":"194.50",
    "squareoff":"0",
    "stoploss":"0",
    "quantity":"1"
    }