Getting Null response from api

SwatiDesale
SwatiDesale edited September 2021 in Node JS client
I'm trying to get access_token using 'https://api.kite.trade/session/token' by passing request_token but get null response sometimes. the issue is not frequent, it is working fine sometimes but get issue without any error message which is very difficult to find the root cause
  • sujith
    Can you run in debug mode and paste the complete stack trace here?
    Make sure to remove app and client specific tokens.
  • SwatiDesale
    const get_access_token = async (request_token,check_sum,api_key) => {
    let url = 'https://api.kite.trade/session/token';
    var post_data = querystring.stringify({
    api_key : api_key,
    'request_token': request_token,
    'checksum': check_sum
    });
    return new Promise(function (resolve, reject) {
    request.post({
    headers: {'content-type' : 'application/x-www-form-urlencoded'},
    url: url,
    body: post_data
    }, function(error, response, body){
    if (!error && response.statusCode == 200) {
    resolve(body);
    } else {
    console.log(error);
    reject(error);
    }
    });
    });
    }

    this is the function where I'm trying to get the access token and when try to console the error get the null value
  • rakeshr
    Can you add the catch block and try printing the error message?
    Make sure, you are passing request_token,check_sum,api_key values properly.
  • SwatiDesale
    yes, it is within try but there also error is printed as null, request token is right same code is running, this scenario is comming rarely once in 2-3 request consecutively with same account and can't use anather code plz suggest the fix(if any) with in this only

Sign In or Register to comment.