具有多个引用的Drupal 8 PATCH节点字段

时间:2018-08-31 19:44:27

标签: rest drupal

我创建了一个带有实体引用字段的内容类型,该字段可以具有多个条目。我正在尝试使用REST服务更新此数据,但我不了解如何构造json。 这是GET调用的结果

{
    "nid": [
        {
            "value": 7
        }
    ],
    "uuid": [
        {
            "value": "c92f1038-7363-40c9-970e-1930b6f3b5c0"
        }
    ],
    "vid": [
        {
            "value": 13
        }
    ],
    "langcode": [
        {
            "value": "it"
        }
    ],
    "type": [
        {
            "target_id": "match",
            "target_type": "node_type",
            "target_uuid": "865f7a5a-15c8-43d6-be5c-cb3be98d894c"
        }
    ],
    "revision_timestamp": [
        {
            "value": "2018-08-29T20:39:28+00:00",
            "format": "Y-m-d\\TH:i:sP"
        }
    ],
    "revision_uid": [
        {
            "target_id": 1,
            "target_type": "user",
            "target_uuid": "df3b85fd-8e60-4577-a92e-4a9f694dfeb1",
            "url": "/fb/user/1"
        }
    ],
    "revision_log": [],
    "status": [
        {
            "value": true
        }
    ],
    "title": [
        {
            "value": "Partita modificata"
        }
    ],
    "uid": [
        {
            "target_id": 1,
            "target_type": "user",
            "target_uuid": "df3b85fd-8e60-4577-a92e-4a9f694dfeb1",
            "url": "/fb/user/1"
        }
    ],
    "created": [
        {
            "value": "2018-08-28T20:00:59+00:00",
            "format": "Y-m-d\\TH:i:sP"
        }
    ],
    "changed": [
        {
            "value": "2018-08-29T20:45:51+00:00",
            "format": "Y-m-d\\TH:i:sP"
        }
    ],
    "promote": [
        {
            "value": true
        }
    ],
    "sticky": [
        {
            "value": false
        }
    ],
    "default_langcode": [
        {
            "value": true
        }
    ],
    "revision_translation_affected": [
        {
            "value": true
        }
    ],
    "path": [
        {
            "alias": null,
            "pid": null,
            "langcode": "it"
        }
    ],
    "body": [
        {
            "value": "How are you?",
            "format": null,
            "processed": "<p>How are you?</p>\n",
            "summary": null
        }
    ],
    "field_data": [
        {
            "value": "2018-09-09T08:00:00"
        }
    ],
    "field_players": [
        {
            "target_id": 1,
            "target_type": "node",
            "target_uuid": "d07eb2aa-91bb-4ac2-9a87-1976be03672c",
            "url": "/fb/node/1"
        },
        {
            "target_id": 8,
            "target_type": "node",
            "target_uuid": "95812a2e-2cca-4461-a9f3-c59a89022232",
            "url": "/fb/node/8"
        },
        {
            "target_id": 1,
            "target_type": "node",
            "target_uuid": "d07eb2aa-91bb-4ac2-9a87-1976be03672c",
            "url": "/fb/node/1"
        },
        {
            "target_id": 8,
            "target_type": "node",
            "target_uuid": "95812a2e-2cca-4461-a9f3-c59a89022232",
            "url": "/fb/node/8"
        }
    ]
}

我如何更新field_players字段以添加具有补丁请求的其他玩家?

预先感谢

0 个答案:

没有答案