Hi, Im trying to make a script that will award every badge inside of a roblox game and im trying to use an api to do this, i dont have any api experience so i am struggling, i have this so far,
local apiUrl = "https://badges.roblox.com/v1/universes/4979760840/badges?sortOrder=Asc"
local success, response = pcall(function()
return HttpService:GetAsync(apiUrl, Enum.HttpContentType.ApplicationJson)
end)
if success then
local responseData = HttpService:JSONDecode(response)
for _, badgeInfo in ipairs(responseData.data) do
print("Badge ID:", badgeInfo.id)
print("Badge Name:", badgeInfo.name)
end
else
warn("Failed to fetch badges:", response)
end
I keep getting the error
Failed to fetch badges: Unable to cast token to bool
anything would be useful
ok sorry for not analyzing the code, I saw that it was in a Pcall and that’s why I got confused, it seems silly but I could see that the Id is typed correctly and that the enumeration is correct, do you get the service right? do you know how the HttpService works?
To access the Roblox Web API, utilizing a proxy is essential. My recommendation is to employ roproxy for this purpose! The designated link takes the following form:
local apiUrl = "https://badges.roproxy.com/v1/universes/4979760840/badges?sortOrder=Asc"
local response = HttpService:GetAsync(apiUrl, Enum.HttpContentType.ApplicationJson)
local responseData = HttpService:JSONEncode(response)
for _, badgeInfo in ipairs(responseData.data) do
print("Badge ID:", badgeInfo.id)
print("Badge Name:", badgeInfo.name)
end