Data Pull Failed with Error - Couldn't parse the JSON response received from the server: b''


  • After stablishing the connection to SmartAPI, I am trying to pull the historic data. While pulling the data I am getting this error: Data Pull Failed with Error - Couldn't parse the JSON response received from the server: b''

    Kindly help me.
    Regards,
    TheM3


  • Same error while testing place_order() functionality

    #place order
    try:
        orderparams = {
            # "variety": "NORMAL",
            "tradingsymbol": "DIL",
            "symboltoken": "8657",
            "exchange": "NSE",
            "transactiontype": "BUY",
            "ordertype": "MARKET",
            "producttype": "CNC",
            "price": "7.8",
            "duration": "DAY",
            "triggerprice" : "7.8",
            "squareoff": "9",
            "stoploss" : "5",
            "trailingStopLoss" : "0.1",
            "disclosedquantity" : '1',
            "quantity": "1",
            "ordertag" : "testing",
            }
        # Method 1: Place an order and return the order ID
        orderid = smartApi.placeOrder(orderparams)
        logger.info(f"PlaceOrder : {orderid}")
        # Method 2: Place an order and return the full response
        response = smartApi.placeOrderFullResponse(orderparams)
        logger.info(f"PlaceOrder : {response}")
    except Exception as e:
        logger.exception(f"Order placement failed: {e}")
    
    raise ex.DataException("Couldn't parse the JSON response received from the server: {content}".format(
        SmartApi.smartExceptions.DataException: Couldn't parse the JSON response received from the server: b''
    

  • Hello @TheM3
    Could you please share the request body and header so that we can have a look on it
    Regards,
    SmartAPI Team