Help with PostAsync

So I’m trying to use Soldier’s ranking API for automatic promotion and stuff, and I used the code below.

local http = game:GetService("HttpService")
local api = "https://api.soldier-bot.tk/ranking/rank"
local auth = ""

local data = {
    ['robloxId'] = 1200418133;
    ['username'] = "DhaniWork";
    ['rank'] = 2
}
local encodedData = http:JSONEncode(data)
    
http:PostAsync(api, encodedData, Enum.HttpContentType.ApplicationJson, false, {['apikey'] = auth})
    
player:Kick("You have been promoted.")

(I removed the auth key and changed the username to another person.)

I believe I did it as intended in the picture below.

It always error as HTTP 400 (Bad Request) but I don’t really know what I did wrong here.

Could it be possible that you might need to change 'rank' as a String Value?

    ['rank'] = "2"

image

Sorry for the late reply! I’ll give it a try.

I tried it out, but it still gave me an HTTP 400 (Bad Request)

Definitely not midnight here ahaha

Do you have HTTP Requests turned on in your Game Settings?

Yeah I did, also I changed the code to this:

http:PostAsync(api, encodedData, Enum.HttpContentType.ApplicationJson, false, {['Authorization'] = "Basic "..auth})

Which I took from a code written by the API owner, and now it just errors “Unauthorized”. So I believe I’m gonna ask the person who made the API instead.

(You should really go to sleep though)