Issue with api licence checker script

My code:

local httpService = game:GetService("HttpService")
local groupService = game:GetService("GroupService")
local apiUrl = "http://##############/v1/check" -- hastagged for private reasons

local function GetOwnerID(): number
	if game.CreatorType == Enum.CreatorType.Group then
		return groupService:GetGroupInfoAsync(game.CreatorId).Owner.Id
	elseif game.CreatorType == Enum.CreatorType.User then
		return game.CreatorId
	end
end

--[[
local hubID = "66dd90712ffdabb307586249"
local productID = "lzksjl62tsgd6xttgwpkor8azb2d"
]]

local function Whitelist(hubId: string, productId: string, targetUserId: number?): boolean
	local UserID = GetOwnerID()

	if typeof(hubId) ~= "string" then error("hubId must be a string") end
	if typeof(productId) ~= "string" then error("productId must be a string") end
	if typeof(targetUserId) ~= "number" and targetUserId ~= nil then error("targetUserId must be a number") end

	local requestData = {
		hubID = hubId,
		productID = productId,
		robloxID = targetUserId
	}

	local requestBody = httpService:JSONEncode(requestData)

	local headers = {
		["Content-Type"] = "application/json"
	}

	local success, response = pcall(function()
		return httpService:PostAsync(apiUrl, requestBody, Enum.HttpContentType.ApplicationJson, false, headers)
	end)

	if success then
		local responseData = httpService:JSONDecode(response)

		if responseData.status == "200" then
			print("License is valid for user: " .. UserID)
			return true
		elseif responseData.status == "104" then
			warn("License is invalid for user: " .. UserID .. " - No whitelist found.")
			return false
		else
			warn("Unexpected response for user: " .. UserID)
			return false
		end
	else
		warn("Failed to check license for user: " .. UserID)
		return false
	end
end

Whitelist("66dd90712ffdabb307586249", "lzksjl62tsgd6xttgwpkor8azb2d")

it worksf ien but then outputs: “Failed to check license for user: 5719020886 - Server - Core_V2:55”

the server is up and runnign with0 errors, i can even access the url with the data in my browser. Can anyone help?

print response and see what it returns

says “Failed to check license for user: 5719020886
Header “Content-Type” is not allowed! - Server - Core_V2:55”

Roblox doesn’t allow you to directly pass the content type through the headers dictionary, you need to do it through the third parameter of post which you’re already doing.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.