Hello, I have a question about HTTP service and JSON decoding.
(This thing worked before)
local gameProxy = Proxy:Get('https://api.roblox.com/universes/get-universe-containing-place?placeid='..var) -- Var is the PlaceID (Fully functional)
print(gameProxy)
local gameProxyUniId = HttpService:JSONDecode(gameProxy).data[1].UniverseId
print(gameProxyUniId)
gameProxy in line 1 outputs like this:
gameProxyUniId in line 5 outputs like this:
In Google Chrome when I type in the URL manually I get this:
local HttpService = game:GetService('HttpService')
--[[
Put your proxy setup here blah blah.
--]]
local PlaceId = 000000 -- GameId // PlaceId
local gameProxy = Proxy:Get('https://api.roblox.com/universes/get-universe-containing-place?placeid='..PlaceId)
local universeId = HttpService:JSONDecode(gameProxy.body).UniverseId
local gameProxy = Proxy:Get('https://api.roblox.com/universes/get-universe-containing-place?placeid='..var) -- Var is the PlaceID (Fully functional)
print(gameProxy)
local response = HttpService:GetAsync(gameProxy)
local gameProxyUniId = response.data[1].UniverseId
print(gameProxyUniId)
Your data is already decoded, not sure why you’re feeding a non-JSON to JSONDecode. You can just directly work with the contents of the table that are returned from gameProxy.
As for accessing the data, there is no data table - your code is telling you that you’re attempting to index something that doesn’t exist (the data key) with a number (1), so consider getting rid of that and just accessing UniverseId directly. I don’t know what the gameProxy table looks like expanded so I assume this is the case, but if it isn’t please do screenshot the expanded table in the output.
local gameProxy = Proxy:Get('https://api.roproxy.com/universes/get-universe-containing-place?placeid='..var) -- Var is the PlaceID (Fully functional)
print(gameProxy)
local response = HttpService:GetAsync(gameProxy)
local gameProxyUniId = response.data[1].UniverseId
print(gameProxyUniId)
Your data is in the body key which is a JSON object. This is what you’re going to want to access, there’s no data key either in the HTTP response or the JSON itself.
local gameProxyUniId = HttpService:JSONDecode(gameProxy.body).UniverseId