I am attempting to edit cards in trello using the PUT method in HttpService.
However at the same line as:
print(ReturnDecoded)
I get an error “Unable to cast to value”.
if string.lower(card.name) == string.lower(User.Name) then
print("Player is on list.")
OnList = true
local PlayerName = User.Name
local Description = "KNOWN MEMBER"
local List = "5feadac75471a94a8c4f50a4"
local CardId = card.id
local data = {id = CardId, name = PlayerName, desc = Description}
local EncodedData = HttpService:JSONEncode(data)
print(CardId)
local Return = HttpService:RequestAsync({
Url = "https://api.trello.com/1/cards/"..CardId..Tokey,
Method = "PUT",
Body = EncodedData
})
local ReturnDecoded = HttpService:JSONDecode(Return)
print(ReturnDecoded)
end
I’ve been stuck on this for basically the entire day.
I never really have had experience using RequestAsync nor Trello but I’m pretty sure your URL requires a query such as “cards/CardId?key=”. But without seeing the “Tokey” value I don’t know if you have already provided that.
You can also use a Trello module, just search for it in the devforum. That handles all the backend for you, so you don’t have to think about that.
If you want to do it yourself, you can also take a look at the module, and implent it in your own code.
@sjr04 Your method did fix the error that was coming up, but the expected result seems to still not occur. The goal I had was for the code to edit the card but it seems that even without the error it failed to edit the card. The expected result was “KNOWN MEMBER” in the card’s description but the card stayed the same.
To clarify this is the change I made with your assistance (just incase I did something wrong).
local ReturnDecoded = HttpService:JSONDecode(Return.Body)
print(ReturnDecoded)
@alphajpeg I made sure the key and token were correct by testing the “DELETE” method. Thank you though.
@Boele009 I want to do it myself but I have attempted to search up previous modules to use as an example and a lot of the information I got was from those modules but I did not come across a module that allowed editing a card in trello.