简体   繁体   English

无法从strapi v4中的发布请求将关系数据添加到集合类型

[英]Not able to add relational data to a collection type from post request in strapi v4

So I can add the relational data from the admin panel in strapi, so in this case there is a collection type called reviews and it has many to one relationship with another collection type called products所以我可以在strapi的管理面板中添加关系数据,所以在这种情况下,有一个名为reviews的集合类型,它与另一个名为products的集合类型有多对一的关系

In postman when I add a review I'm not able to add relation to it.在 postman 中,当我添加评论时,我无法添加与它的关系。 Currently I'm adding the relation via id as that is the standard.目前我正在通过 id 添加关系,因为这是标准。

I was able to do in this in v3, but in strapi v4 for some reason the relation is not getting added.我能够在 v3 中做到这一点,但在 strpi v4 中由于某种原因没有添加关系。

I had the same problem and solved it by going to "Settings" > "Users permissions plugins" > "Roles" > "Public" (or "Authenticated", depending on if you want only logged-in users to access it) > "Products" and click "find" and "findOne" and save it.我遇到了同样的问题,并通过转到“设置”>“用户权限插件”>“角色”>“公共”(或“已验证”,取决于您是否只希望登录用户访问它)>“ Products”,然后单击“查找”和“findOne”并保存。

If "find" and "findOne" in a collection aren't enabled for "Public" or "Authenticated" users, then Strapi won't bother finding the id in the collection that the relation is referring to because you haven't allowed those users to access that data.如果集合中的“find”和“findOne”没有为“Public”或“Authenticated”用户启用,那么 Strapi 不会费心在集合中查找关系所引用的 id,因为你没有允许那些用户访问该数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM