stoiveyp / Slack.NetStandard

.NET Core package that helps with Slack interactions
MIT License
41 stars 16 forks source link

Permalink call doesn't work #45

Closed tomer-amir closed 3 years ago

tomer-amir commented 3 years ago

The following call will always fail:

var permalinkResponse = await client.Chat.Permalink(channelId, messageTimestamp);

with the following errors:

[ERROR] missing required field: channel
[ERROR] missing required field: message_ts

Looking at the API seems like the chat.getPermalink states that the preferred method is GET, and although POST does work, it does not support JSON body :(

meaning that this will work:

POST /api/chat.getPermalink HTTP/1.1
Host: slack.com
Accept: application/x-www-form-urlencoded
Authorization: Bearer <token>
Content-Type: application/x-www-form-urlencoded
Content-Length: 48

channel=<some_id>&message_ts=<some_ts>

But this will not:

POST /api/chat.getPermalink HTTP/1.1
Host: slack.com
Accept: application/x-www-form-urlencoded
Authorization: Bearer <token>
Content-Type: application/json
Content-Length: 71

{"channel": <some_id>,"message_ts": <some_ts>}

Looks like MakeJsonCall only makes POST requests with a JSON body, thus will always fail

stoiveyp commented 3 years ago

Hi @tomer-amir, thanks for catching this! I've just released updates v2.13.1 and 2.14.0-beta2, both of which have chat.getPermalink changed to a url encoded request so it should work as expected now.

Let me know if that works for you 👍

tomer-amir commented 3 years ago

That was quick! Tested and seems to work now :)

Thanks @stoiveyp !!!