Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I get card names from Trello via HttpService?

Asked by 9 years ago

Alright, so I am attempting to retrieve the names of cards under a certain list of a Trello board. I am then taking the data I receive from Trello and inserting it into a TextLabel. Below is the code I have, I understand PostAsync and the usage of JSONEncode. However, I am lost with JSONDecode..

function GetTrelloData()
    local data = game:service'HttpService':GetAsync("https://api.trello.com/1/lists/54e7d14c6e58dc8e8fa5dad7/cards?key=6207b69cb6d65e98733481c3edbcf251",game.HttpService:JSONDecode({"true"}))
    wait(1)
    script.Parent.Parent.TextLabel.Text = data
end

script.Parent.MouseButton1Click:connect(GetTrelloData)
1
You shouldn't post private keys on forums! You should get a new key before someone uses it for evil. BlueTaslem 18071 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

The second parameter to GetAsync() is 'nocache'. nocache means if you want what you got to be saved and reused, or if each time you look for that value, it'll use :GetAsync() again

Try the following: Also, I put game:GetService() at the top to neaten things up. What you had was fine however.

http = game:GetService("HttpService")
function GetTrelloData()
local data = http:GetAsync("https://api.trello.com/1/lists/54e7d14c6e58dc8e8fa5dad7/cards?key=6207b69cb6d65e98733481c3edbcf251",true)
local response = data and http:JSONDecode(data) or 'Failed To Return'
print(response)
end

Check if the above prints anything. If it does, then just replace

 print(response)

with

script.Parent.Parent.TextLabel.Text = data
Ad

Answer this question