Attempt to edit Trello cards

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.

Thank you in advance.

The return value of HttpService:RequestAsync is a table of information about the request, so you would do Return.Body.

Hello!

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.

Here’s an example: “https://api.trello.com/1/cards/CARD_ID?key=API_KEY&token=YOUR_TOKEN

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)

What printed out was a table and I went through that table and got this:
https://gyazo.com/85a8806a5c23d5e2dcb9e023f29df78f

Also thank you very much for the help so far.

@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.

If none of the modules here on the devforum, I think the Trello API doesn’t have an endpoint for it, so it probably isn’t possible.

It does according to:
https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-put

There is also a list someone made to what functions they want added to their trello module but “update card” is one of the unfinished ones.

Jakey assisted me with the code, he found that to edit it requires changing the URL as well:

Url = “https://api.trello.com/1/cards/“..CardId..Tokey..”&desc=”…Description,