Inumedia / SlackAPI

.NET Implementation of the Slack team communication platform API.
MIT License
452 stars 243 forks source link

client.PostEphemeralMessage fails and returns with error 'invalid_arguments' #234

Open EyeOfMidas opened 4 years ago

EyeOfMidas commented 4 years ago

I was attempting to build some functionality into my slackbot using the Ephemeral Message and discovered that the baseline call is no longer working. Here is my example code: The top block is how I am calling the provided function, and the bottom block is me building the same call using the Api call.

This call fails with response.error having the value invalid_arguments.

client.PostEphemeralMessage((response) =>
{
   Console.WriteLine("built in call {0}", response.error);
 }, channelId, "built in call", userId);

This succeeds and I see the message show up properly in my slack channel.

var request = new List<Tuple<string, string>>();
request.Add(new Tuple<string, string>("channel", channelId));
request.Add(new Tuple<string, string>("text", "Direct API call"));
request.Add(new Tuple<string, string>("user", userId));
var callback = new Action<PostEphemeralResponse>((response) =>
{
  Console.WriteLine("Direct API call {0}", response.error);
});
client.APIRequestWithToken(callback, request.ToArray());

In both cases I am using the same channelId and userId with the same token. Perhaps I am calling the function incorrectly, so let me know if that's the case.