Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
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

Log in to vote
1
Answered by 6 years ago

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.

Ad

Answer this question