#Activity Logging connected to an API

1 messages · Page 1 of 1 (latest)

tepid lagoon
#

After creating the code, it still doesn't work even though the url and API are correct, can you help me to turn it around somehow?

local Timers = {}
Players.PlayerAdded:Connect(function(Player)
    Timers[Player.UserId] = {
        Start = os.time()
    }
end)

Players.PlayerRemoving:Connect(function(Player)
    Timers[Player.UserId].End = os.time()

    local TotalTime = Timers[Player.UserId].End - Timers[Player.UserId].Start
    
end)

local HttpService = game:GetService("HttpService")

local BASE_URL = "url"
local API_KEY = "1234567890"

local function sendMessage(message)
    local url = string.format("%s", BASE_URL, message)
    local headers = {["X-API-Key"] = API_KEY}
    local success, response = pcall(function()
        return HttpService:PostAsync(url, "", Enum.HttpContentType.ApplicationJson, false, headers)
    end)
    if success then
        local result = HttpService:JSONDecode(response)
        if result.success then
            print(result)
            
        else
            warn("API Error:", result.error or "Unknown error")
        end
    else
        warn("Request failed:", response)
    end
end

str(TotalTime)```
unique spokeBOT
#

studio** You are now Level 1! **studio

tepid lagoon
#

I don't understand how to fix it, but whatever I try it doesn't respond or it tells me Error 400 (Bad Request)

twin forge
#

RequestAsync requires a few more parameters, but it allows you to get the response message so you can get an actual reason it's giving you the 400 error

twin forge
tepid lagoon
twin forge