Created
September 11, 2022 22:49
-
-
Save oyekanmiayo/21a52c453bd8754203ce6bcd389bc969 to your computer and use it in GitHub Desktop.
How to call slack API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See https://developers.google.com/apps-script/guides/services/external | |
// and https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app | |
function fetchListOfChannels() { | |
var options = { | |
'method' : 'get', | |
'contentType': 'application/json', | |
'headers': { | |
'Authorization': 'Bearer <access_token>', | |
} | |
}; | |
var url = "https://slack.com/api/conversations.list" | |
+ "?types=private_channel" | |
+ "&pretty=1"; | |
var response = UrlFetchApp.fetch(url, options); | |
var json = response.getContentText(); | |
var data = JSON.parse(json); | |
Logger.log(data); | |
for (var i = 0; i < data.channels.length; i++){ | |
Logger.log(data.channels[i]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment