Argument 1 missing or nil error and i dont know why

local HttpService = game:GetService("HttpService")

local ApiKey = "madeprivate"

local function PostRequest(ApiKey, UserId, GroupId, RankId)
    local success, response = pcall(function()
        HttpService:RequestAsync(
            {
                Url = "https://madeprivate/setrank?GroupId=" .. GroupId .. "&UserId=" .. UserId .. "&RankId=" .. RankId,
                Method = "POST",
                Headers = {
                    ["Content-Type"] = "application/json",
                    ["ApiKey"] = ApiKey
                },
            }
        )
    end)
    return success, response
end

local success, response = PostRequest("aaaa", 1299019106, 2636810, 17541629)

Whenever i try to run that code, it prints me this error:

Argument 1 missing or nil

Does anyone know why?

Thanks in advance!

Which line does it print on?

30char

This one here

30char here aswell

I don’t know much about this but I think you can do


If success then
     Print(“success”)
else
     Print(“response”)
end

Put that inside the post request script instead of the return part
Then just call the event later

PostRequest()
1 Like

You never passed those arguments to the pcall, Try doing

local success, response = pcall(function(ApiKey, UserId, GroupId, RankId)

instead of

local success, response = pcall(function()

oh wow yes, i see
i’ll try that, thank you!