How to access custom fields?
agross opened this issue · 2 comments
agross commented
Hi,
Many thanks for creating the library!
My question is around Trello's Custom Fields (the PowerUp). Is there a way to access the Custom Fields data from ruby-trello? I tried card.plugin_data
for a card with Custom Fields but it yielded an empty array.
Thanks!
kaydanzie commented
As noted in the description for #250, Trello moved custom fields to its own endpoint and cannot really be access from plugin data anymore. My PR to update this gem is still pending so I just worked around it using HTTParty:
# To get the custom field data for a single card
base_uri = 'https://api.trello.com'
custom_field_endpoint = "/1/cards/#{card.id}/customFieldItems/"
response = HTTParty.get(base_uri + custom_field_endpoint)
JSON.parse(response.body, symbolize_names: true)
agross commented
Many thanks!
I found this works, too:
response = card.instance_variable_get(:@client)
.get("/cards/#{card.id}/customFieldItems/")
json = JSON.parse(response.body, symbolize_names: true)