HttpService:GetAsync() doesn't work?

You can write your topic however you want, but you need to answer these questions:

  1. 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.

  2. 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

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
1 Like

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

Are you doing this on the server or on a localscript?

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

“Script” Instance ClassName so yes server script

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

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";
		})

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

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