Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

"Unable to cast string to token" error while attempting PostAsync?

local http = game:GetService('HttpService')
local urlEncode = function(str) return http:UrlEncode(str) end
local POST = function(url,data) return http:PostAsync(url,data,'ApplicationUrlEncoded') end
local Url = 'https://discordapp.com/api/webhooks/407404186616201216/dcTEEdeNuoIsm3Uwz0ygU7tGx96k2faHYUtBwTdAVyl-4m6YefDNSccvzE96pyz-kH3y'

http:PostAsync(
    Url,
    'contents='..('a'),
    'HttpUrlEncoded'
)

I'm attempting to send a post request every time someone joins my game. The issue that I'm having is that I'm pretty sure this code should work, but when I run it I get the error mentioned in the title. If anyone can help me with this I would really like that. I'm not sure if the data for the post should be a table or a string. From what I read it should be a string.

1 answer

The issue was I was typing the data name incorrect, aswell as the UrlEncoding was incorrect. It is fixed now. Message me if your having this issue and I'll help you out.

This discussion is preserved as it was. New answers, comments, and votes are closed.