Reputation: 31
I'm receiving a name_taken
error when creating a slack channel via the API using the conversations.create
endpoint. My code was working fine up until a couple days ago, but now I get that error no matter what slack workspace I am in, even a brand new one that has no channels other than default ones. The Slack API docs say that the error means "A channel cannot be created with the given name," so it likely isn't because there is already a channel with that name, but I have no idea what else would cause this issue. I also tried testing it in Postman, and I get the same error.
However, if I make the channel name I want to create gibberish, it works. This leads me to believe that it has more to do with my slack configuration than my API request, but I am at a loss as to how. I would really appreciate any help someone could provide. Below is the code that makes the API call, as well as the response I get. Thanks in advance.
Request:
const channelName = 'moxified'
const createdChannel = JSON.parse(await request.post(`https://slack.com/api/conversations.create`, {
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: `token=${slackTokenResponse.authed_user.access_token}&name=${channelName}`, //name may change
}));
Response:
{ok: false, error: 'name_taken'}
Upvotes: 2
Views: 2751
Reputation: 31
After reaching out to a Slack developer, they explained that the interference was coming from the fact that my bot's name was also 'moxified'. To quote them, "Channel namespaces can be taken up by user groups as well as a name of a bot." I still don't get why it was working for so long without issue, but I hope this helps someone else one day :)
Upvotes: 1