Why am I getting a 422 unprocessable entity error when trying to send a JSONEncoded table?

hi, i am attempting to make a basic mod system with airtable. I am trying to make a request that adds an extra record to the list I created. However, when I fire the function I get a 422 unprocessable entity error. I double checked and I am correctly encoding the table body but it still says the body is incorrect.

here is the current code I have that prints the 422 error

function Moderation.banPlayer(Player, reason)
    local success, response = pcall(function()
        local dictionaryResponse = HttpService:RequestAsync({
            Url = URL,
            Method = "POST",
            Headers = {
                ["Content-Type"] = "application/json",
                ["Authorization"] = "BEARER HERE"
            Body = HttpService:JSONEncode({
                ["records"] = {
                    ["fields"] = {
                        ["UserId"] = "2",
                        ["Reason"] = "reason"


    if not success then

Just for reference here is the API documentation’s version of the data I should be sending.


The example shows that records must be an array of dictionaries that have a fields member.

In your code, you have fields directly under records. So records is not an array but a dictionary.

Try this:

                records = {
                        fields = {
                            UserId = "2",
                            Reason = "reason"
1 Like