Sending chat message within Extension

I’m trying to send chat message from my EBS.
Reading

I correctly created JWT with user_id and role and used it as Authorization header.
Added Client-Id and Content-Type headers.
Added broadcaster_id query parameter.
Added text, extension_id and extension_version in json body.

When sending the POST I receive this error
{"error":"Bad Request","status":400,"message":"extension_name cannot be empty"}

There is no extension_name in the docs, I tried to put it in json body but I get the same error.

What I’m missing?

What does your actual request look like?

This is my example https://github.com/BarryCarlyon/twitch_misc/blob/main/extensions/chat/send_chat.js

Hi, actually I’m doing something like this:

//http client pointing to https://api.twitch.tv
auto req = HttpRequest::newHttpRequest();
req->setPath("/helix/extensions/chat");
req->setParameter("broadcaster_id", broadcaster_id);
req->setMethod(HttpMethod::Post);
req->addHeader("Authorization", "Bearer " + token);
req->addHeader("Client-Id", **[extension id]**);
req->setContentTypeString("application/json");

Json::Value reqBody;
reqBody["text"] = message;
reqBody["broadcaster_id"] = broadcaster_id;
reqBody["extension_id"] = **[extension id]**;
reqBody["extension_version"] = "0.0.1"; 
  • You want the broadcaster_id to be a string if it isn’t
  • And you want to only pass/set it in the body not the query string as well that might be throwing a confusion into Twitch. So remove the req->setParameter('broadcaster_id line and retest.

Otherwise we need to check you JWT generation logic.

Hello, sorry for delay.
I tried everything, I removed broadcaster_id from reqBody, I removed Authorization header and got error "401 Authorization header is required" so token is ok. I removed extension_id from reqBody and got an error "400 extension_id parameter is required" so json body is created correctly.
As soon as I provide all required parameters I get the same error:

{"error":"Bad Request","status":400,"message":"extension_name cannot be empty"}

The problem is that I get the error even if I put this param in body or in query params.

This looks like you fell fowl of this reported issue

So on your developer console for your extension the version details have been blanked in error

You are right! Saved again all the info and now the POST call works like a charm.
Thx a lot!