简体   繁体   中英

How to get all customFieldItems from a board if they don't have any values?

Keep things short:

This call: https://api.trello.com/1/boards/<id>/cards/?fields=all&customFieldItems=true (Of cause with key / token )

Will return all cards with each having a property "customFieldItems": [] , but the value only contains data if the cards custom field items has set values.

So how can I get all customFieldItems which are configured for a specific board?

Custom Fields are defined against the board, so you need to query the Boards endpoint, eg:

curl https://api.trello.com/1/boards/${BOARD_ID}/customFields?key=${TRELLO_API_KEY}&token=${TRELLO_TOKEN}

This will return an array of JSON objects that correspond to each Custom Field you have defined (not just the ones that are set on a particular card), eg:

[
  {
    "id": "8c6a9274db4ac31ba3cbd81d",
    "idModel": "560bf4298b3dda300c18d09c",
    "modelType": "board",
    "fieldGroup": "e876ca319520ce6fde0b073213df077664cda39d26385f49cf6e2cbc8ec01801",
    "display": {
      "cardFront": true
    },
    "name": "Points",
    "pos": 8192,
    "options": [
      {
        "id": "5b6a9274db4ac31ba3cbd821",
        "idCustomField": "8c6a9274db4ac31ba3cbd81d",
        "value": {
          "text": "1"
        },
        "color": "none",
        "pos": 20480
      },
      {
        "id": "5b6a9274db4ac31ba3cbd820",
        "idCustomField": "8c6a9274db4ac31ba3cbd81d",
        "value": {
          "text": "2"
        },
        "color": "none",
        "pos": 36864
      },
    ],
    "type": "list"
  },
]

See: https://developers.trello.com/v1.0/reference#boardsidcustomfields

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