# Chat Message from Extension

**URL:** <https://staging-discuss.dev.twitch.com/t/chat-message-from-extension/23712>\
**Category:** Extensions\
**Created:** [January 10, 2020, 2:43pm UTC](https://staging-discuss.dev.twitch.com/t/chat-message-from-extension/23712 "2020-01-10T14:43:31Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![webdnd](https://avatars.discourse-cdn.com/v4/letter/w/34f0e0/32.png) [@webdnd](https://staging-discuss.dev.twitch.com/u/webdnd)\
**Post date:** [January 10, 2020, 2:43pm UTC](https://staging-discuss.dev.twitch.com/t/chat-message-from-extension/23712/1 "2020-01-10T14:43:31Z")

</div>

I am trying to make chat functionality work for an extension I’m designing, but unfortunately I receive an error whenever the function is called:

```
HTTP505: VERSION NOT SUPPORTED - The server does not support, or refuses to support, the HTTP protocol version that was used in the request message.
(Fetch)GET - https://<CLIENT_ID>.ext-twitch.tv/<CLIENT_ID>/<VERSION_NUMBER>/<UNKNOWN_VALUE>/[object%20Object]

```

The function was derived from the one found at the bottom of the [Chat Capabilities in Extensions](https://staging-discuss.dev.twitch.com/t/rfc-0007-chat-capabilities-in-extensions/16775) post:

```
function chatMessage() {

    var url = "https://api.twitch.tv/extensions/" + onAuth.clientId + "/channels/" + onAuth.channelId + "/chat";
    var jwt = onAuth.token;
    var id = onAuth.clientId;
    var message = userID + " has purchased " + productName + ".";

    fetch({
        method: 'POST',
        url: url,
        headers: {
            'Content-Type': "application/json",
            'Client-ID': id,
            'Authorization': "Bearer " + jwt,
        },
        body: { text: message }
    }).catch ((err) => {
        console.log(err);
    });

}

```

The function is also being run from the broadcaster’s extension panel.

Thanks,  
Michael

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [January 10, 2020, 6:37pm UTC](https://staging-discuss.dev.twitch.com/t/chat-message-from-extension/23712/2 "2020-01-10T18:37:09Z")

</div>

> [@webdnd](#):
>
> (Fetch)GET - https://\<EXTENSION\_ID\>.ext-twitch.tv/\<CLIENT\_ID\>/\<VERSION\_NUMBER\>/\<CHANNEL\_ID\>/[object%20Object]

Is wrong…

` var url = "https://api.twitch.tv/extensions/" + onAuth.clientId + "/channels/" + onAuth.channelId + "/chat"` seems to be incorrect in your code

---

<div class="post-metadata">

**Author:** ![webdnd](https://avatars.discourse-cdn.com/v4/letter/w/34f0e0/32.png) [@webdnd](https://staging-discuss.dev.twitch.com/u/webdnd)\
**Post date:** [January 10, 2020, 8:53pm UTC](https://staging-discuss.dev.twitch.com/t/chat-message-from-extension/23712/3 "2020-01-10T20:53:17Z")

</div>

My mistake, I just checked and I was wrong about all that. What it SHOULD have been was:

`(Fetch)GET - https://<CLIENT_ID>.ext-twitch.tv/<CLIENT_ID>/<VERSION_NUMBER>/<UNKNOWN_VALUE>/[object%20Object]`

I’ll edit the post to reflect that.

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [January 10, 2020, 10:11pm UTC](https://staging-discuss.dev.twitch.com/t/chat-message-from-extension/23712/4 "2020-01-10T22:11:13Z")

</div>

Then your URL construct is _still_ wrong becuase it’s got an object on the end instead of chat.

> **[Extensions Reference](https://dev.twitch.tv/docs/extensions/reference/)**
>
> Extensions Reference

---

<div class="post-metadata">

**Author:** ![webdnd](https://avatars.discourse-cdn.com/v4/letter/w/34f0e0/32.png) [@webdnd](https://staging-discuss.dev.twitch.com/u/webdnd)\
**Post date:** [January 11, 2020, 12:23am UTC](https://staging-discuss.dev.twitch.com/t/chat-message-from-extension/23712/5 "2020-01-11T00:23:54Z")

</div>

Okay, so after looking over some fetch documentation I solved the URL problem. It needed to be:

```
fetch(url, {
    method: 'POST',

```

instead of

```
fetch({
    method: 'POST',
    url: url,

```

But, now I get a 404 error from:

`https://api.twitch.tv/extensions/<CLIENT_ID>/<VERSION>/channels/<CHANNEL_ID>/chat/pinned`

and a 400 error from:

`https://api.twitch.tv/extensions/<CLIENT_ID>/<VERSION>/channels/<CHANNEL_ID>/chat`

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [January 11, 2020, 12:44am UTC](https://staging-discuss.dev.twitch.com/t/chat-message-from-extension/23712/6 "2020-01-11T00:44:54Z")

</div>

> [@webdnd](#):
>
> But, now I get a 404 error from:
> 
> `https://api.twitch.tv/extensions/<CLIENT_ID>/<VERSION>/channels/<CHANNEL_ID>/chat/pinned`

Pinned is not a valid end point.

> [@webdnd](#):
>
> and a 400 error from:
> 
> `https://api.twitch.tv/extensions/<CLIENT_ID>/<VERSION>/channels/<CHANNEL_ID>/chat`

Check the body for an error message that may assist

---

<div class="post-metadata">

**Author:** ![webdnd](https://avatars.discourse-cdn.com/v4/letter/w/34f0e0/32.png) [@webdnd](https://staging-discuss.dev.twitch.com/u/webdnd)\
**Post date:** [January 11, 2020, 2:23am UTC](https://staging-discuss.dev.twitch.com/t/chat-message-from-extension/23712/7 "2020-01-11T02:23:00Z")

</div>

Thanks…

The error was:

`Request body was not parsable. Attempted Content-Type: "application/json"`

Got standard chat messages to work by sending it stringified:

`body: JSON.stringify({ text: message })`

As far as /chat/pinned not being a valid end-point; has that functionality been removed, or changed since the article I mentioned in the original post?

---

<div class="post-metadata">

**Author:** ![Dist](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/dist/32/7192_2.png) [@Dist](https://staging-discuss.dev.twitch.com/u/Dist)\
**Post date:** [January 11, 2020, 2:52am UTC](https://staging-discuss.dev.twitch.com/t/chat-message-from-extension/23712/8 "2020-01-11T02:52:30Z")

</div>

I don’t believe the pinned endpoint was ever official supported. The article you linked is an RFC, an announcement of what the plans/thoughts are at the time but doesn’t guarantee any of that will make it to the finished product, or without changes.

If you want to know what endpoints are supported and their requirements for use, refer to the docs as that is the definitive source of supported endpoints, not the forums.

---

<div class="post-metadata">

**Author:** ![webdnd](https://avatars.discourse-cdn.com/v4/letter/w/34f0e0/32.png) [@webdnd](https://staging-discuss.dev.twitch.com/u/webdnd)\
**Post date:** [January 11, 2020, 3:28am UTC](https://staging-discuss.dev.twitch.com/t/chat-message-from-extension/23712/9 "2020-01-11T03:28:43Z")

</div>

Thanks for the information. I had swore that I saw messages being pinned to a chat or two, but that must of been some other way. I’ll take another look over the docs sometime.

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [January 11, 2020, 12:06pm UTC](https://staging-discuss.dev.twitch.com/t/chat-message-from-extension/23712/10 "2020-01-11T12:06:39Z")

</div>

> [@webdnd](#):
>
> Thanks for the information. I had swore that I saw messages being pinned to a chat or two, but that must of been some other way.

Pinned messages are not a thing in vanilla chat at all.

> [@webdnd](#):
>
> I’ll take another look over the docs sometime.

Send a message to chat docs are here, I linked them earlier

> **[Extensions Reference](https://dev.twitch.tv/docs/extensions/reference/)**
>
> Extensions Reference

---

<div class="post-metadata">

**Author:** ![webdnd](https://avatars.discourse-cdn.com/v4/letter/w/34f0e0/32.png) [@webdnd](https://staging-discuss.dev.twitch.com/u/webdnd)\
**Post date:** [January 11, 2020, 1:10pm UTC](https://staging-discuss.dev.twitch.com/t/chat-message-from-extension/23712/11 "2020-01-11T13:10:17Z")

</div>

Thanks again.
