HTTP 400 (Bad Request) error

Hellow everyone, i’m want use discrod webhook as a message that the number of group members has changed, but I have an error. What is wrong here and how to fix it?

local HttpService = game:GetService("HttpService")
local url = "discord webhook url"


local function GetMemberCount(GroupID)

	local Base = "https://groups.roproxy.com/v1/groups/"

	local Request = HttpService:GetAsync(Base .. GroupID)

	local Data = HttpService:JSONDecode(Request)

	return Data.memberCount

end
if GetMemberCount(here group id) > 63639 then
	local data = {
		["content"] = "ping me",
		["embed"] = {
			["title"] = "test",
			["description"] = "test",
			["color"] = 16711680
		}}
	
	local finaldate = HttpService:JSONDecode(data)
	HttpService:PostAsync(url, finaldate)
else
	print(GetMemberCount(here group id))
end

image

discord webhook can send multiple embeds

local HttpService = game:GetService("HttpService")
local url = "discord webhook url"


local function GetMemberCount(GroupID)

	local Base = "https://groups.roproxy.com/v1/groups/"

	local Request = HttpService:GetAsync(Base .. GroupID)

	local Data = HttpService:JSONDecode(Request)

	return Data.memberCount

end
if GetMemberCount(here group id) > 63639 then
	local data = {
		["content"] = "ping me",
		["embeds"] = {
			{
				["title"] = "test",
				["description"] = "test",
				["color"] = 16711680
			}
		}
	}
	
	local finaldate = HttpService:JSONDecode(data)
	HttpService:PostAsync(url, finaldate)
else
	print(GetMemberCount(here group id))
end

(i changed embeds value into an array)

image

local HttpService = game:GetService("HttpService")
local url = "discord url"


local function GetMemberCount(GroupID)

	local Base = "https://groups.roproxy.com/v1/groups/"

	local Request = HttpService:GetAsync(Base .. GroupID)

	local Data = HttpService:JSONDecode(Request)

	return Data.memberCount

end
if GetMemberCount(5211428) > 63639 then
	local data = {
		["content"] = "ping me",
		["embeds"] = {
			{
				["title"] = "test",
				["description"] = "test",
				["color"] = 16711680
			}
		}
	}

	local finaldate = HttpService:JSONDecode(data)
	HttpService:PostAsync(url, finaldate) --here 29 line 
else
	print(GetMemberCount(5211428))
end

below this line put print(finaldate) then screenshot what it outputs

Your using :Decode instead of :Encode, encode converts lua table into a JSON one, decode is turning a JSON into a lua table.

1 Like

I sent a request using postman & a random group and I got this.


It seems as you can’t send requests to this without any cookies, therefore you can’t get any info from that site.

The problem was in use :Decode , i needed to use :Encode
(it’s working, thanks NightCode_ProGamer)
image

2 Likes

That, and you need to use a proxy in order to send requests from roblox to discord.(You might’ve already done this)

Discord has blocked all inbound requests from Roblox. This shouldn’t work unless you proxy the url.

keep in mind that you have to provide an array for embeds

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.