HTTP service error: Trust check failed

Hi,
I am making something as rover (because of rover is offline most of the time), but I have problem with roblox HTTP service. I use this code:

local HttpService = game:GetService("HttpService")

local dataFields = {
	TOKEN="MY TOKEN",
	ROBLOXID=165696103
}
 
-- The pastebin API uses a URL encoded string for post data
-- Other APIs might use JSON, XML or some other format
local data = ""
for k, v in pairs(dataFields) do
	data = data .. ("&%s=%s"):format(
		HttpService:UrlEncode(k),
		HttpService:UrlEncode(v)
	)
end
data = data:sub(2) -- Remove the first &
 
 
-- Make the request
local response = HttpService:PostAsync("l-ver.glitch.me/getverifying", data)
-- The response will be the URL to the new paste (or an error string if something was wrong)
print(response)

but it gives error: l-ver.glitch.me/getverifying: Trust check failed. Is this possible to repair, or do I need to change hosting?

4 Likes

I’m no expert with HttpService nor web development but I can try helping since it’s from the Lua side.

According to the documentation for PostAsync, it seems that you need to explicitly specify your HttpContentType. The default is ApplicationJson, but you’re making use of UrlEncode, so you need to specify that the content you’re sending over is with Url encoding applied.

You can fix this just by adding in a third parameter, which accepts a HttpContentType Enum. You’ll want to use ApplicationUrlEncoded here to match what you’re doing with your data.

-- Make the request
local response = HttpService:PostAsync("l-ver.glitch.me/getverifying", data, Enum.HttpContentType.ApplicationUrlEncoded)
-- The response will be the URL to the new paste (or an error string if something was wrong)
print(response)

Considering your code sample does come from PostAsync and that also incorporates Url encoding, you should probably follow in their steps as well.

3 Likes

Add http:// in front of your link. Or https:// if the site supports that.

1 Like

This works, but IDK why, i cant see the post info in the node js (but when i try to make post request by some app as postman, it works)

This works, meaning adding the http:// or https:// to the front works? Because what it’s doing is telling Roblox, “Hey, use Hyper Text Transfer Protocol (HTTP) to reference this link” without it, Roblox will return a trust check failed because it needs the http:// or https:// to verify it.

I can’t find where it’s stated anymore, but it used to say that on the wiki.

Yes, but in node js, I cant find the post data, but when i simulate the post request by some app, the node js is working.

What do you mean you can’t find the post data? As in, you can’t see the data you’re sending in the request on the site?

Yes, when i try to write them to console in the node js app, its undefined (but I am not saying, that i am doing it corectly, but with postman, it works).

Weird, have you tried printing them before you send them? To see what the string is and if it’s actually getting put in there?

Yes, its ok.
BTW, the node js code is

app.post("/getverifying", (request, response) => {
  if (request.query.APITOKEN == process.env.APITOKEN) {
    if (request.query.ROBLOXID) {
      var key = "id:" + request.query.ROBLOXID
      if (verify[key]) {
        response.send(verify[key].discordMember.user.username+"#"+verify[key].discordMember.user.discriminator);
      } else {
        response.send("User not verifying");
      }
    } else {
      response.send("Invalid id");
    }
  } else {
    response.send("Invalid token");
    console.log(request.query)
  }
});

and the log output {}.

ok, i found, that in lua, i have TOKEN, but in node js APITOKEN, but i repaired it and nothing changed

I tried editing the node js code and its working :tada: !
But IDK why, the app for simulating post requests isnt working.