I get a error called “HTTP 422 (Unprocessable entity)” when trying to use Pastebin’s API.
Why? for my Script Builder.
Module
local n = {}
local op = {}
local http = game:GetService('HttpService')
function op:GetPaste()
local url = self.baseurl.."api_post.php"
local df = {
["api_user_key"] = self.userkey,
["api_dev_key"]=self.devkey,
["api_option"]='list'
}
print(url,df)
df = format_df(df)
local res = http:PostAsync(url, df, Enum.HttpContentType.ApplicationJson, false)
print(res)
end
function n:new(data)
local devkey = data.devkey
local user = data.user
local pass = data.pass
local userkey = data.userkey
local fa = {devkey=devkey,userkey=userkey,user=user,pass=pass,baseurl="https://pastebin.com/api/"}
fa = setmetatable(fa,{__index=op,__metatable="locked."})
return fa
end
return n
Script(The Caller)
-- MOST CODE LEFT OUT FOR SECURITY PURPOSES.
local PastebinAPI = require(script.EssentialModules.PastebinAPI)
local Data = PastebinAPI:new({devkey="REDACTED",
user="REDACTED",
pass="REDACTED",
userkey='REDACTED'})
print(Data:GetPaste())
I figured the issue was semantic error, which confused me down to the bone.
I have verified that the table was built/headers were made correctly, heck i’ve even removed everything in the table and left it blank, but it kept returning that error.
I also verified that the HttpContentType was correct, infact i’ve tried every single HttpContentType and I still get that error.