Getting an HTTP 400 error from an unfamiliar API script, can’t really figure out what the issue is.
Code:
--[[ START OF SETTINGS ]]--
-- *Following settings removed for security reasons.
local board = ""
local key = ""
local token = ""
local listName = ""
--[[ END OF SETTINGS ]]--
--[[ Tutorial Stuff ]]--
--[[
Trello cards should be formatted like following:
Card Name: Username
1st Line: Top Line of Name
2nd Line: Bottom Line of Name
3rd Line: R,G,B colour for the title.
To get your trello app key visit the below URL and replace key with it:
https://trello.com/app-key
To get your trello API token visit the following URL and copy the 2nd string (it should be 32 characters):
https://trello.com/app-key
The board should be set as the URL board link:
https://trello.com/b/HERE/
--]]
--[[ Setting Important Stuff ]]--
game.StarterPlayer.NameDisplayDistance = 0
game.StarterPlayer.HealthDisplayDistance = 0
--[[ END OF IMPORTANT STUFF ]]--
-- Setting up variables & services
local url = "https://api.trello.com/1/boards/" .. board .. "/lists?cards=open&card_fields=name,desc&filter=open&fields=name&key=" .. key .. "&token=" .. token;
local rank = script:WaitForChild('OverheadRank')
local http = game:GetService("HttpService");
-- Function to get team from brickcolor
function GetTeamFromColor(TeamColor)
for i,v in pairs(game:GetService('Teams'):GetChildren()) do
if v.TeamColor == TeamColor then
return v -- Return Team
end
end
return false -- Return false
end
-- Declaring cache variable for use by update and get rank object
local cache;
function replaceVars(player, input)
local down = string.lower(input);
local hasGroupRole, endOf = string.find(down, "#grouprole:");
if (hasGroupRole ~= nil) then
local cut = string.sub(down, endOf + 1);
local groupId = string.sub(cut, 1, string.find(cut, "#") - 1);
input = string.gsub(input, string.sub(input, endOf - 10, endOf + string.len(groupId) + 1), player:GetRoleInGroup(tonumber(groupId)));
end
input = string.gsub(input, "#username#", player.Name);
return input;
end
function createOverheadObject(player)
if (cache) then
for i,v in ipairs(cache) do
if (string.lower(v.name) == string.lower(player.Name)) then
local desc = v.desc;
local nlPos = string.find(desc, "\n");
local above = replaceVars(player, string.sub(desc, 1, nlPos - 1));
local below = replaceVars(player, string.sub(desc, nlPos + 1));
local c;
local nlPosColor = string.find(string.sub(desc, nlPos + 2), "\n");
if (nlPosColor ~= nil) then
nlPosColor = nlPosColor + nlPos;
local below = replaceVars(player, string.sub(desc, nlPos + 1, nlPosColor));
local t = string.split(string.sub(desc, nlPosColor + 2), ",");
c = Color3.fromRGB(t[1], t[2], t[3]);
return above, below, c;
end
return above, below, c;
-- Group:GROUPID
elseif (string.sub(string.lower(v.name), 1, 5) == "group") then
local group = string.sub(v.name, 7);
if (player:IsInGroup(tonumber(group))) then
local desc = v.desc;
local nlPos = string.find(desc, "\n");
local above = replaceVars(player, string.sub(desc, 1, nlPos - 1));
local below = replaceVars(player, string.sub(desc, nlPos + 1));
local c;
local nlPosColor = string.find(string.sub(desc, nlPos + 2), "\n");
if (nlPosColor ~= nil) then
nlPosColor = nlPosColor + nlPos;
local below = replaceVars(player, string.sub(desc, nlPos + 1, nlPosColor));
local t = string.split(string.sub(desc, nlPosColor + 2), " ");
c = Color3.fromRGB(t[1], t[2], t[3]);
return above, below, c;
end
return above, below, c;
end
end
end
end
return false;
end
game:GetService('Players').PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
-- When a character respawns
local Head = Character:WaitForChild('Head')
local team = GetTeamFromColor(Player.TeamColor)
local teamRank
local textServ = game:GetService('TextService')
local playerID = Player.UserId
if team then
-- If team has an integer value called GroupId then get the role for the group
-- If it doesn't then set it as the team name
if team:FindFirstChild('GroupId') then
teamRank = Player:GetRoleInGroup(team.GroupId.Value)
else
teamRank = team.Name
end
end
local tag = rank:Clone()
local user = tag:WaitForChild('User')
local rankClone = tag:WaitForChild('Rank')
local PlayerName = Player.Name
-- Everyone's Titles
user.Text = Player.Name
rankClone.Text = teamRank
user.TextColor3 = Player.TeamColor.Color
rankClone.TextColor3 = Color3.fromRGB(255, 255, 255)
local above, below, c = createOverheadObject(Player);
-- if a user has a custom rank then
if (above ~= false and above ~= nil) then
user.Text = above;
rankClone.Text = below;
-- If 3rd line is a colour
if (c) then
user.TextColor3 = c;
rankClone.TextColor3 = Color3.fromRGB(255, 255, 255)
end
end
-- Setting Back
tag.Parent = Head
end)
end)
function updateTrelloCache() -- error line
local jsonResponse = http:GetAsync(url);
local returnedResponses = http:JSONDecode(jsonResponse);
for i,v in ipairs(returnedResponses) do
if (v.name == listName) then
cache = v.cards;
returnedResponses = {};
end
end
end
updateTrelloCache();
while (true) do
wait(30);
updateTrelloCache();
end
-- This was made by K_ieraH and Nucl3arPlayz
Line where the error is coming from can be found on 185, I also marked it with a comment