HttpService error, HTTP 400 (Bad Request)

Hey!

I’m not sure what’s wrong. I tried changing the Data variable to “Hi”, but it doesn’t seem to work either.

Anyone got a fix?

local function SecurePlayer(Player)
	local HttpService = game:GetService("HttpService");
	local JoinURL = "Webhook";
	
	local Data = {
		["content"] = nil;
		["embeds"] = {
			["title"] = "Player has joined the server!";
			["description"] = "Player '".. Player.Name .."' has joined the server. \n ".. game.JobId;
			["color"] = nil;
		};
	};
	
	Data = HttpService:JSONEncode(Data);
	HttpService:PostAsync(JoinURL, Data);
end

game:GetService("Players").PlayerAdded:Connect(SecurePlayer);

Is that a real endpoint?
Did you parse the json right for the BE? Are those valid arguments?

1 Like

It’s okay, I fixed it. I’m not sure what I did wrong, and I couldn’t get it to work with the embed, so I just rewrote it as a module with another type of embed.

Embeds take embed objects but you didn’t make any, you put data directly into the embeds table which is not a valid format for the endpoint.

["embeds"] = {
    {
        ["title"] = "",
        -- ...
    }
}