Can't Parse JSON?

I’ve been trying to get a game’s current servers. It says I am not able to Parse the JSON. I have been researching and it tells me I need to grab the Response Body/the string I’m trying to decode instead of the URL. I will provide images down below.

ROBLOX Serversided Code:

local HTTP = game:GetService("HttpService")
local ServerURL = "https://games.roblox.com/v1/games/5690297562/servers/Public?sortOrder=Asc&limit=25"
local ServerData = HTTP:JSONDecode(ServerURL)

print(ServerData)

Error: image

ROBLOX Game API Website:

I’m basically trying to get the Response Body to JSONDecode, but I’m having trouble understanding how to get there.

I also tried using HTTP:GetAsync in order to get something if it was able to get anything lol, but it did not work.

Hopefully you guys can help and learn alongside with me (:

Links alone aren’t valid JSON. You need to make a web request to that endpoint first, which will return the JSON to decode.

Keep in mind you can’t make requests to *.roblox.com or roblox.com itself using HttpService, so you will have to use a proxy.

3 Likes

So I’d have to use a proxy like glitch, then would I use HTTP:RequestAsync at all? I read some of the documentation and it looked like it would be able to get the information. Or do I just JSONDecode whatever is provided from glitch?

JSONDecode doesn’t go out and fetch the data from a URL. All it does is turn a JSON string into a Lua table. So you’ll have to use RequestAsync to first fetch the data, and then feed it into JSONDecode. And yeah, you’ll have to use a proxy if you’re hitting endpoints within the Roblox domain.

4 Likes