HTTP 400 (Bad request)

I’m trying to make a discord webhook for a rating system. It worked before but when trying to use publix proxies I get the error stated in the title.

http:PostAsync(frSettings.WebhookId,
					http:JSONEncode({
						embeds = {
							['title'] = 'New Rating',
							['type'] = 'rich',
							['description'] = frSettings.Rating1..':'..rating1sentEmoji..'\n\n'..frSettings.Rating2..':'..rating2sentEmoji..'\n\n'..frSettings.Rating3..':'..rating3sentEmoji..'\n\n**Feedback**:\n'..feedback,
							['color'] = frSettings.EmbedColor,
							['footer'] = {
								['text'] = 'Rating System'
							}

						}
					})
					)
				

I think it’s that i’m formatting it wrong. The webhook and other variables are stored in a module script. It worked before I tried changing it up to a proxy once finding about the webhook ban.

Could anyone please help me.

1 Like

Is HttpService set to HttpEnabled = true? This could be the problem

2 Likes

Let me find my Roblox to Discord API that uses RequestAsync.

function Webhook:Execute(data)
	local succ, err = pcall(function()
		local response = httpService:RequestAsync({
			Url = string.format("%s/api/webhooks/%s/%s", DEFAULT_URL, tostring(self._channelId), tostring(self._webhookToken));
			Method = "POST";
			Headers = {
				['Content-Type'] = "application/json";
			};
			Body = httpService:JSONEncode(data);
		});
		
		if not response.Success then
			self.warn("The request failed:", response.StatusCode, response.StatusMessage);
		end;
	end);
	
	if not succ then
		self.warn("Http Request Failed:",err);
	end;
end;

This builds off of a module script that has the variables stored in it. DEFAULT_URL is the proxy I own and made for Discord and Roblox.

1 Like

How would I intergrate my embed into this? And if so use a public api like hooks.hyra.io?

Yes it is. I’m doing a formatting issue for sure. I just need help to format it correctly so it can send to the server.

Does this work for you? Mind the horrible formatting here. :sweat_smile:

    local http = game:GetService("HttpService")
local luaData = 
	{

		["embeds"] = {
			{
				["title"] = "New Rating",
				["type"] = "rich",
				["description"] = frSettings.Rating1..':'..rating1sentEmoji..'\n\n'..frSettings.Rating2..':'..rating2sentEmoji..'\n\n'..frSettings.Rating3..':'..rating3sentEmoji..'\n\n**Feedback**:\n'..feedback,
				['color'] = frSettings.EmbedColor,
				["footer"] = {
					["text"] = "Rating System"
				}
			}
		}
	}

http:PostAsync(frSettings.WebhookId,  http:JSONEncode(luaData))

2 Likes

Thanks for that! Just what I needed, really appreciate it!

2 Likes