'I'm working with the slack analytics api, specifically the admin.analytics.getFile method. I'm running into a strange error when dealing with the response from my call.
Here's the relevant portion of my script for reference;
function getData() {
var analyticsUrl = `https://slack.com/api/admin.analytics.getFile?type=member&date=2023-12-30`;
var analyticsOptions = {
'method': 'GET',
'headers' :{
'accept-encoding': 'gzip',
'Authorization': 'Bearer REDACTED'
}
};
var response = UrlFetchApp.fetch(analyticsUrl, analyticsOptions);
Logger.log(response.getAllHeaders());
var placeholderBlob = response.getBlob().setContentType('application/x-gzip');
Logger.log(placeholderBlob);
Logger.log(Utilities.ungzip(placeholderBlob));
Logger.log(placeholderBlob.getDataAsString())
};
The GET returns a .json.gz file, which I had expected to convert to a blob, and then ungzip using the built in method. Here's the execution logs in order:
- {Access-Control-Allow-Headers=slack-route, x-slack-version-ts, x-b3-traceid, x-b3-spanid, x-b3-parentspanid, x-b3-sampled, x-b3-flags, x-backend=main_normal main_canary_with_overflow main_control_with_overflow, Access-Control-Expose-Headers=x-slack-req-id, retry-after, Vary=Accept-Encoding, x-accepted-oauth-scopes=admin.analytics:read, Referrer-Policy=no-referrer, x-slack-unique-id=ZbEuKziT4Vd-8mjR7E7KJQAAAAo, x-server=slack-www-hhvm-main-iad-wlqz, Pragma=private, x-oauth-scopes=identify,admin.analytics:read, Expires=Sat, 26 Jul 1997 05:00:00 GMT, Content-Length=10961, x-slack-shared-secret-outcome=no-match, Via=1.1 slack-prod.tinyspeck.com, envoy-www-iad-evdldebd, envoy-edge-pdx-morbazdg, Date=Wed, 24 Jan 2024 15:35:07 GMT, Cache-Control=private, Strict-Transport-Security=max-age=31536000; includeSubDomains; preload, x-edge-backend=envoy-www, Content-Type=application/gzip, x-envoy-attempt-count=1, x-slack-edge-shared-secret-outcome=no-match, x-envoy-upstream-service-time=265, Content-Disposition=attachment; filename="NAMEREDACTED.json.gz"; filename*=utf-8''NAMEREDACTED%202023-12-30.json.gz, Server=Apache, Access-Control-Allow-Origin=*, x-slack-backend=r}
- Blob
- Blob
- Logging output too large. Truncating output. (Followed by a load of raw data)
This appears to me that the content-type is correct for passing into ungzip. Why then do I get raw data when the final logger hits the console?
Let me know if I can provide any further context or clarification.