Search code examples
restapitrello

Obtain the cards > customFieldItems object from the boards end point


From a single get request to the Boards end point, is it possible to get the customFieldItems (i.e the custom field values associated with a card)?

When including parameters cards=all and customFields=all, the response returns:

  • a cards object, but without any information relating to the custom fields;
  • a customFields object, but with no way of linking it back to the card it is situated on

I could make additional requests for EACH card to the cards end point to obtain the information, but this would be a lengthy process and I would expect the response from the board end point to provide this information.

When inspecting the board .json file (from the browser) it includes the customFieldItems object within the card object. I am looking for the same information when requesting information from the boards end point.

Am I missing something obvious here?


Solution

  • As you observed, the board resource has both cards and customFields params. Custom Fields are defined at the board level, so that's what the customFields param returns. However, in your case, you want the customFieldItems that are specific to a card.

    For this case, you should refer to the Cards Nested Resource, which includes the parameter you want, card_customFieldItems.

    In short, you could use something like the following (substituting your own board id for <id>):

    curl --request GET --url 'https://api.trello.com/1/boards/<id>?cards=all&card_customFieldItems=true'
    

    The response will include an array of cards, each of which will contain a customFieldItems array, e.g.:

    [
      {
        "id": "5acbd57f7160061ed10daa2c",
        "value": {
          "text": "High Priority"
        },
        "idCustomField": "5ab0f9f30c8780347a255463",
        "idModel": "5acbbe5d615f7dd1935b92f5",
        "modelType": "card"
      }
    ]