HTTP 400 Error Request

I tried to improve roblox chat filter by using a different external chat filter from a website.
Here’s my script:

local HTTPService = game:GetService('HttpService')
local Url = 'https://api.sightengine.com/1.0/text/check.json'
local RequestData = {
	['request'] = {
		["text"] = "Hi, My name is Joe.",
		["mode"] = 'standard',
		['lang'] = 'en',
		['opt_countries'] = 'gb',
		['api_user'] = 'xxxxx',
		['api_secret'] = 'xxxxxxxxxxxxxxx'
	}
}
local RequestData = HTTPService:JSONEncode(RequestData)
local Moderated = HTTPService:PostAsync(Url, RequestData)
print(Moderated)

Any scripts will help!
I got 400 Error Request, any help would be appricated.

1 Like

here’s a little tip:

did you turn on the https service in the security tab in game settings? if not, then you’re should enable it.

I enabled it from command line.

Http Requests are enabled.

oh, understand. but i don’t really know the scripts.

And we have a image of the error?

I’m improving roblox chat filter

Error:
Capture

It seems the api you are using expects all the parameters to be in the url:

Try:

local HTTPService = game:GetService('HttpService')
local text = game:GetService("HttpService"):EncodeUrl(text)
local Url = 'https://api.sightengine.com/1.0/text/check.json?text='..text.."&mode=standard&lang=en&opt%5Fcountries=gb&api%5Fuser=xxxx&api%5Fsecret=xxxxxxxxxxxxxxx" -- make sure to url encode your api_secret and api_user
local RequestData = {
	['request'] = {
		["text"] = "Hi, My name is Joe.",
		["mode"] = 'standard',
		['lang'] = 'en',
		['opt_countries'] = 'gb',
		['api_user'] = 'xxxxx',
		['api_secret'] = 'xxxxxxxxxxxxxxx'
	}
} -- we still use RequestData just in-case some properties are accessed from the post data.
local RequestData = HTTPService:JSONEncode(RequestData)
local Moderated = HTTPService:PostAsync(Url, RequestData)
print(Moderated)
1 Like

i looked at website and i think there’s no need for ‘request’ element try this

local RequestData = {
		["text"] = "Hi, My name is Joe.",
		["mode"] = 'standard',
		['lang'] = 'en',
		['opt_countries'] = 'gb',
		['api_user'] = 'xxxxx',
		['api_secret'] = 'xxxxxxxxxxxxxxx'
}

I don’t think you’re allowed to change the chat filter to an external 3rd party software that Roblox doesn’t use anyway.

I tried that and it still doesn’t work.