dspn
dspn

Reputation: 314

trello API on custom fields using R

I'm trying to update a custom field on trello.

I've gone ahead and created a dummy account to share it's credentials to make sure there is a reproducible example.

require("httr")
PUT("https://api.trello.com/1/cards/5f6888ab6301b68b8a614156/customField/5f6889e2d2536e5364eed893/item?key=d674c81261ea78489bcef67dda228790&token=bdcdd065a63b82fb0e2f5f98a7464791698e4fa98004ec02f2690bce9ce2a59d&value=")
content(GET("https://api.trello.com/1/boards/5f6888aa5f8b800c21e81f6e?key=d674c81261ea78489bcef67dda228790&token=bdcdd065a63b82fb0e2f5f98a7464791698e4fa98004ec02f2690bce9ce2a59d&cards=all&card_fields=all&customFields=true&card_customFieldItems=true"))[["cards"]][[1]][["customFieldItems"]][[1]][["value"]][["text"]]

PUT("https://api.trello.com/1/cards/5f6888ab6301b68b8a614156/customField/5f6889e2d2536e5364eed893/item?key=d674c81261ea78489bcef67dda228790&token=bdcdd065a63b82fb0e2f5f98a7464791698e4fa98004ec02f2690bce9ce2a59d&value=something")
content(GET("https://api.trello.com/1/boards/5f6888aa5f8b800c21e81f6e?key=d674c81261ea78489bcef67dda228790&token=bdcdd065a63b82fb0e2f5f98a7464791698e4fa98004ec02f2690bce9ce2a59d&cards=all&card_fields=all&customFields=true&card_customFieldItems=true"))[["cards"]][[1]][["customFieldItems"]][[1]][["value"]][["text"]]

line 2 I'm trying to delete the value on the field ("please change me from API") line 3 I'm grabbing the value and realizing it's still the same

line 4 I'll try to change the value to "ee" line 5 I'll check that it still isn't working.

the errors are slightly different (404 vs 400) so I'm guessing that I'm very close.

Upvotes: 0

Views: 287

Answers (2)

jakub
jakub

Reputation: 5114

For completeness, you can use the API client:

library(trelloR)
update_card_field(card_id, field = "field_id", key = "text",
                  value = "Updated!")

Upvotes: 1

dspn
dspn

Reputation: 314

took me several days but I finally got it.

For anyone who might have the same problem: instead of using "&value=something" on the url itself you must use the body parameter from PUT. like this:

PUT("https://api.trello.com/1/cards/aa/customField/bb/item?key=cc&token=dd", body = list(value = list("text" = "something")), encode = "json")

it looks like the trello api needs the value to be passed in as json and that it has to be done though the body parameter.

Change aa bb cc dd and something according to what you want "text" also if using a different data type

Upvotes: 1

Related Questions