HTTP 400 (Bad Request)

This script is part of a roblox to discord application center. Here is the code:

submitEvent.OnServerEvent:Connect(function(player, userInputData, appFrameData)
	local dataToSend = {
		['content'] = '',
		['embeds'] = {
			['title'] = userInputData['Title'];
			['description'] = 'Username: '..userInputData['Username'];
			['color'] = '5661687';
			['footer'] = {
				['icon_url'] = 'https://tr.rbxcdn.com/c379b37e1dc253d6dcab6355c4a2272d/150/150/Image/Png';
				['text'] = 'RECRUITMENT CENTER';
			};
			['thumbnail'] = {
				['url'] = userInputData['Avatar'];
			};
			['author'] = {
				['name'] = 'SCP:F | [APOLLYON]';
				['icon_url'] = 'https://tr.rbxcdn.com/c379b37e1dc253d6dcab6355c4a2272d/150/150/Image/Png';
			};
			['fields'] = {
				{
					['name'] = appFrameData['Questions'][1];
					['value'] = userInputData['Answers'][1];
				};
				{
					['name'] = appFrameData['Questions'][2];
					['value'] = userInputData['Answers'][2];
				};
				{
					['name'] = appFrameData['Questions'][3];
					['value'] = userInputData['Answers'][3];
				};
				{
					['name'] = appFrameData['Questions'][4];
					['value'] = userInputData['Answers'][4];
				};
			};
		};
	};
	local finalData = https:JSONEncode(dataToSend)
	print(finalData)
	https:PostAsync(discordHook, finalData)
end)

The error occurs at this line https:PostAsync(discordHook, finalData)

1 Like

replace your Discord webhook from

discord.com or whatever

to

webhook.lewistehminerz.dev/webhook

Problem is discord stopped accepting requests from Roblox due to some issues that Roblox has and is too lazy to fix in HttpService, such as poor headers, etc. Changing to this webhook.lewistehminerz is basically sending the data through a free-to-use proxy and therefore making it work

to be frank I’m not entirely sure how to do that, moreover I tried sending a content-only message and it worked with my current webhook, however it doesn’t work for the whole thing

Well I’m no Http Expert so Idk how to help you in this scenario. One thing is certain and it is that you won’t be able to use your webhooks in-game, only in studio.

Your webhook should look something like this:

instead of

discord.com/webhook

type

webhook.lewistehminerz.dev/webhook

only change discord.com to webhook.lewistehminerz.dev, the rest is still the same

Also, bad request means you typed something wrong, I think you might not need the content = ’ ’ because I don’t remember using that when I didn’t need content, just use embeds

also, the code from this should help you get a better understanding of how this works

1 Like

so from this

https://discord.com/api/webhooks/random letters/more random letters

to this

webhook.lewistehminerz.dev/webhook/random letters/more random letters

no, you don’t actually type webhook :joy:

just from discord.com/your webhook to
webhook.lewistehminerz.dev/your webhook

that still doesn’t seem to be working

try and get inspiration from the link that I sent you, what I told you to do will make it so the webhook gets sent in the game and in studio, if you kept it that way, you wouldn’t be able to use it in game

For discord, I would consider using a proxy such as Discord Webhook Proxy

And make sure you have HTTP enabled in your place

You really read the whole thread before replying :joy:

Please enlighten me, what do you mean?

I think that the main problem was that my data used already JS-encoded fields from the discord webhook api. It works fine now.

1 Like

I already told him about what you said

Oh ok great, thanks for marking my answer as solution :fire:

Dunno, Cosim said that still doesn’t seem to be working so I offered another proxy^^

He said it still wasn’t working because he had other issues as welll