Can't parse JSON


local HttpService = game:GetService("HttpService")
local response = HttpService:RequestAsync({
	Url = ""..4623776635,
	Method = "GET"

local votes = HttpService:JSONDecode(response.Body)

I’m trying to make it print the amount of likes, but it says Can’t parse JSON

Are you sure the body is valid JSON?

That error appers whenever what you pass to JSONDecode() isn’t a valid json string.

You should always wrap API calls in pcalls to handle errors

local success, result = pcall(function()
    return HttpService:RequestAsync(...)

if not success or not result.Success then
    return warn(`Unsuccessful request, failed with status code {result.StatusCode}.`)

if result.Body then

Apparently you are receiving an error instead of the expected response which doesn’t include a valid json body. You can debug it by reading the response’s status code.

1 Like

It says: Unsuccessful request, failed with status code nil.

That means that the error is not in the request because the return of RequestAsync() is a table with a StatusCode key. You probably haven’t turned on HttpRequests in your game’s settings. Try printing result.

1 Like