如果没有任何值,如何从板上获取所有customFieldItems?

时间:2018-04-18 16:06:57

标签: trello trello-powerup

保持简短:

此致电:https://api.trello.com/1/boards/<id>/cards/?fields=all&customFieldItems=true(原因为key / token

将返回所有具有属性"customFieldItems": []的卡片,但如果卡片自定义字段项目设置了值,则该值仅包含数据。

那么我怎样才能获得为特定主板配置的所有 customFieldItems?

1 个答案:

答案 0 :(得分:1)

自定义字段是针对木板定义的,因此您需要查询木板端点,例如:

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

这将返回与您定义的每个自定义字段相对应的JSON对象数组(不仅仅是在特定卡上设置的自定义字段),例如:

[
  {
    "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"
  },
]

请参阅:https://developers.trello.com/v1.0/reference#boardsidcustomfields