I am trying to retrieve the new, "bust" profile picture of a player (the one where it displays your character without any gear item equipped and faces the right side).
According to the wiki article on Web APIs, you have to use that given url to retrieve a JSON table, which you can decode later. That's exactly what I'm trying to do here:
local imageLabel = script.Parent --ImageLabel Object local myJSON = game:GetService('HttpService'):JSONDecode('http://www.roblox.com/bust-thumbnail/json?userId=17030889&height=180&width=180') imageLabel.Image = myJSON[1]
myJSON
should look something like this:
{"Url":"http://t4.rbxcdn.com/6fa936d8b4dc1b86d98f0143bbf20788","Final":true}
However, all I get is an error saying Can't parse JSON
.
The wiki article on JSONDecode says that the JSONDecode function
does not require HttpEnabled
to be true, but I tried it with it both on and off just to be sure, and it still doesn't work.
In addition, I also tried using double-quotes instead of single-quotes for the url, and it still doesn't work.
What am I doing wrong here?
There's two issues here, really. (Though, after refreshing both of them have been addressed by 'DigitalVeer' - Nonetheless, I thought I'd post what I had)
1) JSONDecode's argument is meant to contain the JSON you're decoding; what you've provided isn't JSON - Ipso facto, that error occurs.
local HttpService = game:GetService("HttpService") local Decoded = HttpService:JSONDecode(HttpService:GetAsync("Website"))
2) You cannot use HttpService with ROBLOX URLs, unless you make use of a some website which makes and returns the request for you.
Two ways to get around the second issue:
1) Mimic what that link does; you can use the ImageRectOffset and ImageRectSize properties of ImageLabels to get the desired effect. 2) Make use of 'rproxy' - Though, with this route you have no idea how long the service will be provided for; it could "go away" anytime.