HTTP 400 (Bad Request) error from webhook, cannot find why

Hello.

I’m using this webhook with discord, and I just cannot find why it’s not working. I get an HTTP 400 error code, if you didn’t know. Here is the code.

local data = 
	{
		["content"] = "",
		["embeds"] = {{
			["title"] = "Report",
			["color"] = 0xFF0000,
			["fields"] = {
				{
					["name"] = "User",
					["value"] = user.Name
				},
				{
					["name"] = "Reason",
					["value"] = reason
				},
				{
					["name"] = "Server Id",
					["value"] = jobid
				}
			},
			["thumbnail"] = {
				["url"] = thumbnail
			}
		}}
	}
data = http:JSONEncode(data)
http:PostAsync("hidden", data)

Any help would be appreciated.

1 Like

Enable HTTPS Request in game settings.

2 Likes

HTTPS is already enabled, it’s something to do with the data but I cannot find what.

1 Like

Can you show me the whole code? some variables are missin and make sure your webhook url is correct.

2 Likes

Or, if you want we can talk on discord?

1 Like
local jobid = game.JobId

local data = 
		{
			["content"] = "",
			["embeds"] = {{
				["title"] = "Report",
				["color"] = 0xFF0000,
				["fields"] = {
					{
						["name"] = "User",
						["value"] = user.Name
					},
					{
						["name"] = "Reason",
						["value"] = reason
					},
					{
						["name"] = "Server Id",
						["value"] = jobid
					}
				}
			}}
		}
	data = http:JSONEncode(data)
	http:PostAsync("hidden", data)
1 Like

Also, reason and user and defined somewhere else, I know it’s not causing the problem though.

try:

local jobid = game.JobId

local data = 
		{
			["content"] = "",
			["embeds"] = {{
				["title"] = "Report",
				["color"] = 0xFF0000,
				["fields"] = {
					{
						["name"] = "User",
						["value"] = user.Name
					},
					{
						["name"] = "Reason",
						["value"] = reason
					},
					{
						["name"] = "Server Id",
						["value"] = jobid
					}
				}
			}}
		}
	local toPost = http:JSONEncode(data)
	http:PostAsync("hidden", toPost )
1 Like

Actually, sorry I just solved it. One of my variables were wrong.

Oh alrighty! have a gr8 day! or night!

1 Like

Thank you very much!! Much appreciated.

1 Like