Postback URL Post body malformed

MW5790
I use a google CLoud function to capture the Postback from Kite.
I get a malformed JSON like this.. pls help
Extra ', }

{ '{"placed_by":"PN4653","order_id":"191122003026392","exchange_order_id":"","parent_order_id":"","status":"REJECTED","status_message":"Order was placed outside of trading hours (adapter off). Try placing an AMO.","order_timestamp":"2019-11-22 23:53:20","exchange_update_timestamp":"","exchange_timestamp":"","variety":"regular","exchange":"NFO","tradingsymbol":"NIFTY19NOVFUT","instrument_token":12335874,"order_type":"LIMIT","transaction_type":"SELL","validity":"DAY","product":"NRML","quantity":75,"disclosed_quantity":0,"price":12000,"trigger_price":0,"average_price":0,"filled_quantity":0,"pending_quantity":0,"cancelled_quantity":0,"market_protection":0,"tag":"API","guid":"14109XUiJFZZdSXo1R","user_id":"PN4653","unfilled_quantity":0,"app_id":14109,"checksum":"bedaaa4c2bfefccb53cfcc20917f3c4fb56ee0ba62b2a315c494894e4282da5c"}': '' }"
Tagged:
  • MW5790
    Hi Any response or help
    @tonystark
  • tonystark
    @MW5790 It seems the way you collect the JSON is wrong. Can you post an example code that can reproduce this?
  • MW5790
    This is the Nodejs called triggered from my google cloud function .. in the google console logs i see a malformed JSON

    const escapeHtml = require('escape-html');

    exports.broadcastUpdate = (req, res) => {


    console.log('got incoming broadcast update from -', req.connection.remoteAddress);
    console.log('Request Body -',req.body);
    console.log('tag -',req.body.tag);
    //res.status(200).send({ok: true});

    console.log('Content type-',req.get('content-type'));
    res.status(200).send('Source IP-'|| req.connection.remoteAddress
    );
    };


    JSON in Google console logs

    { '{"placed_by":"PN4653","order_id":"191128003614894","exchange_order_id":"","parent_order_id":"","status":"REJECTED","status_message":"Order was placed outside of trading hours (adapter off). Try placing an AMO.","order_timestamp":"2019-11-28 21:58:01","exchange_update_timestamp":"","exchange_timestamp":"","variety":"regular","exchange":"NSE","tradingsymbol":"HDFC","instrument_token":340481,"order_type":"LIMIT","transaction_type":"BUY","validity":"DAY","product":"NRML","quantity":250,"disclosed_quantity":0,"price":2320,"trigger_price":0,"average_price":0,"filled_quantity":0,"pending_quantity":0,"cancelled_quantity":0,"market_protection":0,"tag":"API","guid":"14597XP9arePiaUj5D","user_id":"PN4653","unfilled_quantity":0,"app_id":14597,"checksum":"e0b2fad09e38cfb6eaca7c225123844641ecaf7f42960c513382b3999ca7bac6"}': '' }"

Sign In or Register to comment.