Get UniverseId from PlaceID

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:
image

gameProxyUniId in line 5 outputs like this:
image

In Google Chrome when I type in the URL manually I get this:
image

SOLUTION (for people who have the same error)
Using: https://github.com/sentanos/ProxyService

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)

this MAY or MAY NOT help

image

print(game.GameId)

https://developer.roblox.com/en-us/api-reference/property/DataModel/GameId

1 Like

I’m NOT looking for my UniverseId.

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 gameProxyUniId = gameProxy.UniverseId
1 Like

Thank you for your answer.

GameProxyUniId outputs as this:
image

As for the gameProxy it outputs this:
image

Expanding the message I get this:
image

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)

should fix it

1 Like

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

i legit see no difference in mine are your code

I editted the url with a proxy

oh ok it was a subtle change so yea