Solved

Error running analytics/export API

  • 30 December 2022
  • 1 reply
  • 89 views

Badge +2
 I have been running into some issues while trying to get the results of analytics/exports. Whenever I try and execute the request I get 0 progress and an error message(below).
 
Error Message: {"_error":{"status":401,"title":"Unauthenticated","message":"JSON Web Token error"}}
Here is all the code if it helps:
import requests

url = "https://api2.frontapp.com/analytics/exports"
payload = {
    "start": 0,
    "end": 1652970430,
    "type": "messages"
}

headers = {
    "Accept": "application/json",
    "Content-Type": "application/json",
    "Authorization": "Bearer MY_TOKEN_VALUE"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)

 

icon

Best answer by Support Engineering 30 December 2022, 19:56

View original

1 reply

Userlevel 1
Badge +5

Note that calling the Create new Export endpoint creates an export job - this takes time (sometimes several minutes) to run. You need to call the fetch export endpoint with the ID returned in the initial call to check the progress of the export, and eventually fetch the CSV export from the provided URL. So you’re likely running successful exports that just haven’t finished yet.

 

--Jason

Reply