Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to use httpservice?

hs = game:GetService("HttpService")
test = hs:GetAsync("http://www.roproxy.tk/Asset/AvatarAccoutrements.ashx?userId=57686851", true)
print(test)

This one printed the body of the html

hs = game:GetService("HttpService")=
test = hs:GetAsync("http://www.roproxy.tk/Asset/AvatarAccoutrements.ashx?userId=57686851", true)
local Items = hs:JSONDecode(test)

when i tried to decode the JSON this error came out Can't parse JSON

now i want to use the data i obtained to turn it into a character changing appearance without dying is there a way to turn the data to a table?

1 comment

0

I can't help much more then this, look up more information about it on Roblox Wiki: http://wiki.roblox.com/index.php?title=HttpService_for_Dummies

1 answer

There is a CharacterAppearance Property of Players might be more useful for this.

Now, to answer your question: Because it's in JSON, you first have to decode it into a Table, this can be done Via:

local URLs = {}
hs = game:GetService("HttpService")
test = hs:GetAsync("http://www.roproxy.tk/Asset/AvatarAccoutrements.ashx?userId=57686851", true)
for String in string.gmatch(test, "(.-);") do 
URLs[#URLS + 1] = String;
end

4 comments

0

Can't parse JSON

0

Oh, look at that, it's not returnning JSON, let me modify the code above

0

There, changed to fix it, basically, it's using gmatch from the string library to catch the URLs which are conveniently separated by semicolons

0

Do note the last one doesn't end with a semi-colon, so something more like "([^;]+)" (anything not a semicolon+) would work better. Edited your answer move the link from plaintext to an actual link with text.

This discussion is preserved as it was. New answers, comments, and votes are closed.