HTTP Requests Help

Hi! I am sending information to my HTTP database when a user joins the server for a log, how could I include the os.date and UserId in the message below.

game.Players.PlayerAdded:connect(function(player)

HookData.content = ("**" .. player.Name .. "**" .. " has joined the server!")

HTTP:PostAsync(Key, HTTP:JSONEncode(HookData))

end)```
1 Like

Where exactly are you trying to put the os.date and their UserId? Also, this would be the way I would put it, you can use it if you want:

HookData.content = (os.date..": **" .. player.Name .. "("..player.UserId..")" .. "**" .. " has joined the server!")

How would you like to include the data? Do you want to send a dictionary or include it in the string message currently being sent?

I just need to include the os.date, player name and userID all in one request just so we can review the access logs for statistical purposes.

Iā€™d just store each of them under a separate key in HookData then. HookData.date = os.date("%c") or whatever.

2 Likes

Will definitely be better you you used a dictionary for this. For the time, the ISO8601 would be the most conventional.

ie.

HookData.content = {
    name = player.Name
    userId = player.UserId,
    time = os.date("%Y-%M-%DT%H:%m:%sZ")
}