HTTP 422 (Unprocessable entity)

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.

1 Like

I found these:

If the name of the file is tagged in Roblox, it cannot be uploaded.

1 Like

This has nothing to do with my thread.
Please read what I have said.

Hello Obj_ective!

It appears like you forgot to use HttpService:JSONEncode() on your table you are trying to Post.

This should be an easy fix by just encoding the table you are sending.

1 Like

Unfortunately, it still presents HTTP 422. I have removed the query/header format function and only passed on the encoded table, and it presented it. When I put it back, it just errors cause it’s a string, and no longer a table.

Hello Obj_ective!

1 Like

I understand what that is trying to do, but would I really be able to access any paste with that code?
I am trying to access a private one, so it is not visible to others(not companies, dnc about them).