Hello! I am trying to create a function that will pull all of the users that have been created by a specific player. This url accepts a userId to pull gamepass information. For some reason, this is resulting in an error that says “HTTPError: InvalidUrl.” I am not sure what is causing this error.
NOTE: I have redacted the actual URL for security. The redacted section is just some words, no special characters or numbers.
EDIT: This is a script in ServerScriptService
local function GetAllUserGamepasses(userId)
assert(type(userId) == "number" or type(userId) == "string", "userId must be a number or string")
local passes = {}
local cursor = nil
local baseUrl = "http://pull.[redacted].com?userId="..tostring(userId)
repeat
-- Build URL safely
local url = baseUrl
if cursor and cursor ~= "" then
url = url.."&cursor="..HttpService:UrlEncode(tostring(cursor))
end
-- Make HTTP request in ServerScript
local success, response = pcall(function()
return HttpService:GetAsync(url, true) -- true = JSON response not wrapped
end)
if not success then
warn("HTTP failure:", response)
break
end
-- Decode JSON safely
local decoded
local ok, err = pcall(function()
decoded = HttpService:JSONDecode(response)
end)
if not ok then
warn("JSON decode failure:", err)
break
end
-- Insert passes
if decoded.data then
for _, item in ipairs(decoded.data) do
table.insert(passes, item)
end
end
-- Update cursor for next page
cursor = decoded.nextPageCursor
until not cursor or cursor == "" -- stop if no more pages
return passes
end