Can't Parse JSON error?

So, I’m trying to get game data (such as player count), to do this I am using this code:

local RS = game:GetService("ReplicatedStorage")
local HttpService = game:GetService("HttpService")

local Remotes = RS.Remotes
local getGameData = Remotes.GetGameData

getGameData.OnServerInvoke = function(player, gameId)
	local data = HttpService:GetAsync("https://games.rprxy.com/v1/games?universeIds="..gameId)
	print(data)
	local json = HttpService:JSONDecode(data)
	return json
end

However, I get a Can't Parse JSON error, anyone know why? (also got this url from a dif DevForum post solution)

Here is the output of data (which is clearly not JSON btw):

<!doctype html><html lang="en"><head><meta http-equiv="content-type" content="text/html;charset=utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon"/><title></title><script src="https://www.google.com/adsense/domains/caf.js" type="text/javascript"></script><noscript><style>#content-main{display:none}</style><div>For full functionality of this site it is necessary to enable JavaScript. Here are the <a target="_blank" rel="noopener noreferrer" href="https://www.enable-javascript.com/">instructions how to enable JavaScript in your web browser</a>.</div></noscript><script type="application/javascript">window.LANDER_SYSTEM="CP"</script></head><body><div id="contentMain"></div><script>!function(e){function r(r){for(var n,a,i=r[0],l=r[1],p=r[2],c=0,s=[];c<i.length;c++)a=i[c],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&s.push(o[a][0]),o[a]=0;for(n in l)Object.prototype.hasOwnProperty.call(l,n)&&(e[n]=l[n]);for(f&&f(r);s.length;)s.shift()();return u.push.apply(u,p||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++){var l=t[i];0!==o[l]&&(n=!1)}n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={1:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)a.d(t,n,function(r){return e[r]}.bind(null,n));return t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p="https://img1.wsimg.com/parking-lander/";var i=this["webpackJsonpparking-lander"]=this["webpackJsonpparking-lander"]||[],l=i.push.bind(i);i.push=r,i=i.slice();for(var p=0;p<i.length;p++)r(i[p]);var f=l;t()}([])</script><script src="https://img1.wsimg.com/parking-lander/static/js/2.fd9305fa.chunk.js"></script><script src="https://img1.wsimg.com/parking-lander/static/js/main.b2dc4f09.chunk.js"></script></body></html>

its either too long, or there is nothing to encode

1 Like

Pretty sure that link is dead since pasting it into a browser takes you to a dodgy website.

1 Like

In that case, do you know another link I can use?

Unfortunately, most of the Roblox proxy services were taken down since they got too popular or were just no longer being kept up-to-date. Your best option is to make or host one yourself. I’m pretty sure there are lots of open source proxies on github specifically made for Roblox, so just shove one of those on a cheap VPS and have a private proxy.

Well, thanks but I don’t wanna have to pay for this side project, I guess that feature isn’t the most necessary

Although this information may not be very useful since @sleepyAyla already has explained why this won’t work in its current form, it may still be good to know for future reference:

You are getting this error because, as you said, you are not receiving a JSON. You are receiving the HTML of the site, this is because the website in question isn’t a JSON. Roblox Groups Api (groups.roblox.com) is an example of a JSON response.

Yeah, I am familiar with JSON (and HTML, since I used to do web dev more, and still do)

you missspelled roproxy :wink:

local RS = game:GetService("ReplicatedStorage")
local HttpService = game:GetService("HttpService")

local Remotes = RS.Remotes
local getGameData = Remotes.GetGameData

getGameData.OnServerInvoke = function(player, gameId)
	local data = HttpService:GetAsync("https://games.roproxy.com/v1/games?universeIds="..gameId)
	print(data)
	local json = HttpService:JSONDecode(data)
	return json
end

example output:

{"data":[]}
1 Like

Well, I got that link from another devforum post, however, since that post, rprxy has been shutdown. also, I don’t think roproxy exists as I get a 400 bad request error

1 Like