"Can't Parse JSON" Error

I’m trying to create Nitro Booster Perks. The code below works perfectly in the studio but for some reason it errors Can't Parse JSON when I test it in-game. If you read the code below, you can see which line errors for me.

game.Players.PlayerAdded:Connect(function(player)
	local http = game:GetService("HttpService")
	local api = "https://discord.com/api/guilds/514884314144702504/members/search?query="
	
	local data  = http:RequestAsync({
		Url = api..player.Name,
		Headers = {
			["Authorization"] = "Bot (token)"
		}
	})
	
	local boostData = http:JSONDecode(data.Body)[1]["premium_since"] -- THIS LINE CAUSES ERRORS
	
	if boostData ~= nil then
		isbooster(player)
	end
	
end)

Any help works, thanks.

1 Like

That script is lacking the method parameter in the request async function

It’s not required – by default, it performs a GET request


@OP The endpoint probably did not return json. Try printing the response before attempting to parse the response to json

1 Like

Good chance it didn’t return a valid JSON string, you should wrap JSONDecode() inside pcall() in future.

Hiya, I dont think this is related to the reason you opened this, however please note discord is blocking roblox requests so you’d probably be needing to send it to an external server. I know this is the case with webhooks, but I am unsure about the state of what your doing currently. :slight_smile: