soxtoby / SlackNet

A comprehensive Slack API client for .NET

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PostToWebhook should allow for JSON building blocks

sebastienlabine opened this issue · comments

I love strong typing, but I feel like we could benefit from sending raw json instead of a strongly typed message when using PostToWebhook.

Task PostToWebhook(string webhookUrl, Message message, CancellationToken? cancellationToken = null);

I am actually in a progress of migrating lots of precompiled json message blocks and I would pretty much prefer just to copy the raw json.

Task PostToWebhook(string webhookUrl, Message message, CancellationToken? cancellationToken = null);
Task PostToWebhook(string webhookUrl, string json, CancellationToken? cancellationToken = null);

Thanks for the suggestion @sebastienlabine, but once you take the typing and serialization out of PostToWebhook, I'm not sure what value SlackNet would be providing. Webhooks don't require authentication, and they don't return anything in the response, so there isn't anything Slack-specific left.

I'd suggest making with request with HttpClient directly:

using var httpClient = new HttpClient();
await httpClient.PostAsync("<webhook URL>", new StringContent("<JSON>", Encoding.UTF8, "application/json"));

Hope this helps.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.