What's wrong here? (HttpService error)

What did I do wrong here? Errors with “HTTP 400 (Bad Request”)

function encodeJSON(Text)
	local HttpService = game:GetService("HttpService");
	
	local messageData = {
		["contents"] = Text;
	};
	
	messageData = HttpService:JSONEncode(messageData);
	return messageData;
end;

function postRequest(URL, Data)
	local HttpService = game:GetService("HttpService");
	
	HttpService:PostAsync(URL, Data)
end;

function sendWebhook(Text)
	local Webhook = "https://discord.com/api/webhooks/xxx/xxx"; -- Don't want to get spammed.
	
	local Message = encodeJSON(Text);
	postRequest(Webhook, Message);
end;

wait(5);
sendWebhook("testing this bro");

It should be content, not contents

2 Likes

I’d be careful using Discord webhooks.

They’ve suspended accounts that are the authors of webhooks that receive large amounts of activity.

Also, as Embat said, the request needs “content” rather than “contents”.

1 Like

I’m not gonna use them for something big, I’ll try to be careful. I also heard there was a way around it by changing something in the URL, do you know about that?

Uhh, not sure. You’d have to ask around.