Answered

Why is nothing returned when I try to export message data through the API? (Version 2.2)

  • 2 November 2020
  • 3 replies
  • 87 views

Hi,

I’ve been trying to pull out data from the message export model, as detailed here: https://developers.intercom.com/intercom-api-reference/v0/reference#export-job-model

 

Everything here “works” in the sense that there are no errors, and I get 200 http response codes, but when it comes to downloading the data at the end, there doesn’t appear to be any!

 

The app I’m making this for is Python-based, but using curl directly gives the same results:

 

---

 

First, set up an export job (in this case exporting the last 10 days of messages):

curl https://api.intercom.io/export/messages/data -X POST -H ‘Authorization:Bearer <token>’ -H “Intercom-Version: Unstable” -H ‘Accept: application/json’ -H ‘Content-Type: application/json’ -d ‘{“created_at_after”: 1603407600, “created_at_before”: 1604275200}’

 

As expected, this gives a response like

{“job_identifier”:<job-id>,“status”:“pending”,“download_url”:“”,“download_expires_at”:“”}

 

---

 

Secondly, check status:

curl https://api.intercom.io/export/messages/data/<job-id> -X GET -H ‘Authorization:Bearer <token>’ -H “Intercom-Version: Unstable” -H ‘Accept: application/json’

 

which gives a response like

{“job_identifier”:<job-id>,“status”:“complete”,“download_url”:“https://api.intercom.io/download/messages/data/message-data-export.no-data-timeframe”,“download_expires_at”:<timestamp>}

 

---

 

Finally, pinging the download_url above (and just telling it to dump any raw data in console to see if there’s anything):

curl https://api.intercom.io/download/messages/data/message-data-export.no-data-timeframe -X GET -H ‘Authorization:Bearer <token>’ -H “Intercom-Version: Unstable” -H ‘Accept: application/octet-stream’ --output -

 

But when I do this, nothing appears. Similar story in the Python environment - specifically on the final step I have a requests response object, but looking at its content (response.content) just returns an empty bytes object (b’’).

 

---

 

Unless I’m being horribly misled we should have message data available - according to the reports in the customer engagement UI, we send a few hundred each day.

 

The two question marks I have right now are:

  • The default API version is 2.2 (I think) - passing “Intercom-Version: Unstable” in the request headers seems to work, but maybe things are more nuanced than that?
  • The url returned to download data from seems suspiciously generic: https://api.intercom.io/download/messages/data/message-data-export.no-data-timeframe - the no-data-timeframe seems to imply that the time bounds aren’t being picked up properly, but that’s confusing considering I do send them, and get an error if I don’t anyway.

 

Any pointers in solving this very appreciated!

icon

Best answer by Eric Fitz 6 November 2020, 17:09

View original

3 replies

Userlevel 1

Hey @sam a12​, you're correct that this endpoint is currently only accessible via our Unstable API version for now, so you'll need to make sure that the unstable version is specified in the request headers.

 

As for the timeframe in your export link, let me check in with our team who manage our API, and I'll come back to you when I have an update!

Thank you!

Userlevel 1

Thanks so much for your patience here, @sam a12​! The team advise me that, if no.data.timeframe is showing here, it means that no messages were found in the timeframe you specified.

 

However, if that's definitely not the case, let me know!

Reply