Why I receive {“ok”:false,“error”:“channel_not_found”} when I am setting topic in slack?

Tags: ,

Here is my code for setting topic channel and I receive {"ok":false,"error":"channel_not_found"} while the channel exists and I tried to use channelId instead of using #channelName . but no difference. And the permissions are set correct.

function setTopic1() {
var topic = 'testing'
  var url = 'https://xxxx.slack.com/api/conversations.setTopic'
  var payload = {
    'channel': '#temp-w',
    'token': token,
    'topic': topic,

  var options = {
    'method': 'post',
    'payload': payload,

  if (topic.length > 250) {
    Logger.log("Topic is too long, API request might fail")
  var response = UrlFetchApp.fetch(url,options);


I found what was the issue. First as we integrate bot to channel ,I also needed to invite @channelName. And in payload it would be correct instead of using #channelName to channelID. It didn’t work for me with channelName, it works with channelName when I posted message in channel but for set channel it works with channelId in payload

Source: stackoverflow