如何通过Contentful中的对象数组进行查询

问题描述 投票:1回答:1

我在Contentful中有一个内容类型条目,其中包含以下字段:

"fields": {
                "title": "How It Works",
                "slug": "how-it-works",
                "countries": [
                    {
                        "sys": {
                            "type": "Link",
                            "linkType": "Entry",
                            "id": "3S5dbLRGjS2k8QSWqsKK86"
                        }
                    },
                    {
                        "sys": {
                            "type": "Link",
                            "linkType": "Entry",
                            "id": "wHfipcJS6WUSaKae0uOw8"
                        }
                    }
                ],
                "content": [
                    {
                        "sys": {
                            "type": "Link",
                            "linkType": "Entry",
                            "id": "72R0oUMi3uUGMEa80kkSSA"
                        }
                    }
                ]
            }

我想运行一个只返回包含特定国家/地区的条目的查询。

我玩这个查询:

https://cdn.contentful.com/spaces/aoeuaoeuao/entries?content_type=contentPage&fields.countries=3S5dbLRGjS2k8QSWqsKK86

但是得到这个错误:

The equals operator cannot be used on fields.countries.en-AU because it has type Object.

我正在玩邮递员,但将使用.NET API。

是否可以搜索实体,并筛选包含对象的数组?

还在学习API,所以我猜它应该是非常直接的。

更新:

我查看了Contentful Web CMS的请求,因为此功能是可行的。他们使用这样的查询参数:

filters.0.key=fields.countries.sys.id&filters.0.val=3S5dbLRGjS2k8QSWqsKK86

但是,这在传递API中不起作用,并且可能只是内部查询格式。

contentful
1个回答
1
投票

想出这个。我使用了以下网址:

https://cdn.contentful.com/spaces/aoeuaoeua/entries?content_type=contentPage&fields.countries.sys.id=wHfipcJS6WUSaKae0uOw8

请注意查询参数fields.countries.sys.id

© www.soinside.com 2019 - 2024. All rights reserved.