简体   繁体   中英

Trello Card Update API

I have been trying to play around a little with Trello's REST API. So far I am able to push some cards into the system with the regular POST call. What I would like to do now is to update a card with new information (ie new description, new comments or move the card to new list etc.).

Can I do this with a PUT- or a POST-method or do I first need to delete the old card and create a new one? If so, could anybody give an example of how they're doing this?

I've tried the following PUT-method, but it didn't seem to work:

PUT https://api.trello.com/1/cards/[existing card id]?key=[key]&token=[TOKEN]

and then I'll supply the parameters in the body of the request, like this:

{
    "id": "542de77c832cff3f97884ad8",
    "badges": {
        "votes": 0,
        "viewingMemberVoted": false,
        "subscribed": false,
        "fogbugz": "",
        "checkItems": 0,
        "checkItemsChecked": 0,
        "comments": 0,
        "attachments": 0,
        "description": true,
        "due": null
    },
    "checkItemStates": [],
    "closed": false,
    "dateLastActivity": "2014-10-03T00:02:04.042Z",
    "desc": "test",
    "descData": null,
    "due": null,
    "idBoard": "5417684179931e027c3d6bb9",
    "idChecklists": [],
    "idList": "5417684179931e027c3d6bbc",
    "idMembers": [],
    "idShort": 14,
    "idAttachmentCover": null,
    "manualCoverAttachment": false,
    "labels": [],
    "name": "new test #1 updated",
    "pos": 131072,
    "shortUrl": "https://trello.com/c/XYZ",
}

By the way, I am using Postman Client to execute my HTTP-methods. In the end I want to implement these functions into a small javascript module. Does anyone have an idea what I am doing wrong?

Thanks in advance!

Allright so it has been quite some time but now I faced the same issue the last few hours. For me the trick with the x-www-form-urlencoded body didn't work out.

For the people that are still struggling:

1.) Every parameter you want to change has to be defined in the Query-Params - no body is needed

2.) make sure to type in the URL as https:// and not http:// ! This actually solved the issue.

It seems like the Trello Api interprets every http:// request as GET.

have fun! :-)

Using insomnia rest client, it worked using PUT + body content as json. Adding fields in the url wasn't necessary.

* Preparing request to https://api.trello.com/1/cards/card_id?key=your_key&token=some_token
* Current time is 2020-08-07T11:28:18.144Z
* Using libcurl/7.69.1 OpenSSL/1.1.1g zlib/1.2.11 brotli/1.0.7 libidn2/2.1.1 libssh2/1.9.0 nghttp2/1.40.0
* Using default HTTP version
* Disable timeout
* Enable automatic URL encoding
* Enable SSL validation
* Enable cookie sending with jar of 1 cookie
* Found bundle for host api.trello.com: 0xa7f54da37800 [can multiplex]
* Re-using existing connection! (#4) with host api.trello.com
* Connected to api.trello.com (96.7.239.40) port 443 (#4)
* Using Stream ID: 3 (easy handle 0xa7f54da37800)

> PUT /1/cards/card_id?key=your_key&token=some_token HTTP/2
> Host: api.trello.com
> user-agent: insomnia/2020.3.3
> cookie: dsc=blablabla
> content-type: application/json
> accept: */*
> content-length: 20

{"desc":"123123123"}

* We are completely uploaded and fine

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM