XDify01
(XDify01)
May 9, 2021, 6:35am
#1
You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I am trying to create a command to execute user-generate code from a link containing the raw code format.
What is the issue? Include screenshots / videos if possible!
HttpService:GetAsync() does not seem to work no matter what I do.
elseif string.find(msg, "g/h/") then
local cl = string.sub(msg, 5)
print(cl)
print(HttpService:GetAsync(cl))
Output:
13:31:48.605 https://pastebin.com/raw/G0g0eavk - Server - Handler:98
13:31:48.606 - Server - Handler:98
Command:
g/h/https://pastebin.com/raw/G0g0eavk
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
1 Like
XDify01
(XDify01)
May 9, 2021, 6:43am
#2
Tried using string.gsub() instead of string.sub() and it didn’t work aswell.
elseif string.find(msg, "g/h/") then
local cl = string.gsub(msg, "g/h/", "")
print(cl)
print(HttpService:GetAsync(cl))
13:42:00.549 https://pastebin.com/raw/G0g0eavk - Server - Handler:98
13:42:00.549 - Server - Handler:98
1 Like
ZYTRXS
(ZYTRIS)
May 9, 2021, 6:48am
#4
Are you doing this on the server or on a localscript?
XDify01
(XDify01)
May 9, 2021, 6:48am
#5
Just tried to use HttpService:RequestAsync() and the result is quite intresting but confusing…
13:47:47.919 ▼ {
[“Body”] = “print(“test”)”,
[“Headers”] = ▼ {
[“age”] = “1379”,
[“cache-control”] = “public, max-age=1801”,
[“cf-cache-status”] = “HIT”,
[“cf-ray”] = “64c8fa813ef219b0-SIN”,
[“cf-request-id”] = “09f17ae4c4000019b0eb116000000001”,
[“connection”] = “keep-alive”,
[“content-encoding”] = “gzip”,
[“content-type”] = “text/plain; charset=utf-8”,
[“date”] = “Sun, 09 May 2021 06:47:48 GMT”,
[“expect-ct”] = “max-age=604800, report-uri=“https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct ””,
[“server”] = “cloudflare”,
[“set-cookie”] = “__cfduid=d5275a02ceef3ba115a97d0eee4994c6e1620542868; expires=Tue, 08-Jun-21 06:47:48 GMT; path=/; domain=.pastebin.com ; HttpOnly; SameSite=Lax; Secure”,
[“transfer-encoding”] = “chunked”,
[“vary”] = “Accept-Encoding”,
[“x-content-type-options”] = “nosniff”,
[“x-frame-options”] = “DENY”,
[“x-xss-protection”] = “1;mode=block”
},
[“StatusCode”] = 200,
[“StatusMessage”] = “OK”,
[“Success”] = true
} - Server - Handler:98
edit: [“Body”] returns the correct thing, gonna make adjustments
XDify01
(XDify01)
May 9, 2021, 6:49am
#6
“Script” Instance ClassName so yes server script
ZYTRXS
(ZYTRIS)
May 9, 2021, 6:50am
#7
Now this is what you call a dictionary, and RequestAsync includes the ‘body’ which is what you are trying to get.
Try this:
HttpService:RequestAsync(link here).Body
Then you can loadstring it
XDify01
(XDify01)
May 9, 2021, 6:50am
#8
That is not how RequestAsync works I think (I followed HttpService | Roblox Creator Documentation )
local cl = string.gsub(msg, "g/h/", "")
local result = HttpService:RequestAsync({
Url = cl;
Method = "GET";
})
ZYTRXS
(ZYTRIS)
May 9, 2021, 6:51am
#9
Oh yeah, sorry, I forgot about the methods and how HTTP requests really work, but yeah try that
local cl = string.gsub(msg, "g/h/", "")
local result = HttpService:RequestAsync({
Url = cl;
Method = "GET";
}).Body
XDify01
(XDify01)
May 9, 2021, 6:53am
#10
Thank you to @ZYTRXS for helping me, in the end we solved it by using HttpService:RequestAsync() instead of HttpService:GetAsync()
local cl = string.gsub(msg, "g/h/", "")
local result = HttpService:RequestAsync({
Url = cl;
Method = "GET";
})
print(cl)
print(result.Body)
2 Likes