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?
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.
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, 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).