Forum Discussion

manthena2020's avatar
10 months ago

Issue in capturing historical data

Hi I have  issue in capturing  historical data. i am getting this error 

Response Status: 200
Response Body: b'{"data":null,"errmsg":"Invalid time range. Start time must be before current time","status":1007}'
No 'values' field found in the 'data' section of the JSON response.

  • Anonymous's avatar
    Anonymous

    Print out your start_timestamp and your yesterday_timestamp and put them into postman. If it doesn’t work there it’s not going to work in your code. 

    You might need to divide both timestamps by 1000 before casting to int. I don’t remember if LM wants seconds or milliseconds and i don’t remember which one python gives you.

  • if i use this i am getting data

    current_timestamp = int(datetime.utcnow().timestamp())

    start_timestamp = int((datetime.utcnow() - timedelta(days=30)).timestamp())
    queryParams =  f'?start={start_timestamp}&end={current_timestamp}'
    print(start_timestamp)

    From today to last 30 days we are getting data

    epoch = str(int(time.time() * 1000))  ( both the cases we are using this)