POST 创建条目的请求未将字段映射到 Strapi 中的另一个集合

POST request to create entry is not mapping fields to another collection in Strapi

有 3 个集合、法官、法院和程序。在以法院、法官、案卷(PDF)、开始日期和结束日期为字段的诉讼程序中创建新条目时,我可以使用媒体库中的 ID 映射案卷(PDF),但对法院和法官不起作用。

这是我创建条目的 POST 调用:

{
    "startdate": "2020-11-10",
    "enddate": "2020-11-25",
    "judge": {
        "id": 1
    },
    "docket": {
        "id": 1
    },
    "court": {
        "id": 1
    }
}

我的回复是:

{
    "id": 24,
    "startdate": "2020-11-10",
    "judge": {},
    "enddate": "2020-11-25",
    "court": {},
    "created_by": null,
    "updated_by": null,
    "created_at": "2020-11-25T09:11:08.338Z",
    "updated_at": "2020-11-25T09:11:08.360Z",
    "docket": [
        {
            "id": 1,
            "name": "Agenda-1.pdf",
            "alternativeText": "",
            "caption": "",
            "width": null,
            "height": null,
            "formats": null,
            "hash": "Agenda_1_708f0363ef",
            "ext": ".pdf",
            "mime": "application/pdf",
            "size": 282.99,
            "url": "/uploads/Agenda_1_708f0363ef.pdf",
            "previewUrl": null,
            "provider": "local",
            "provider_metadata": null,
            "created_by": 1,
            "updated_by": 1,
            "created_at": "2020-08-17T14:07:45.656Z",
            "updated_at": "2020-08-17T14:07:45.862Z"
        }
    ]
}

我如何映射法院和法官字段,就像案卷一样?

你试过吗:

{
    "startdate": "2020-11-10",
    "enddate": "2020-11-25",
    "judge": 1,
    "docket": {
        "id": 1
    },
    "court": 1
}

我猜你可以有多个 docket 因为它在输出中是一个数组,但对于 judgecourt 可能只有一个。所以你可以像那里那样做:https://strapi.io/documentation/v3.x/content-api/api-endpoints.html#create-an-entry