4

I have a problem with fetching third level data from Strapi CMS.

My Structure is the following:

Page > Content(Dynamic Zone) > Multiple Entitys e.g. HeroSliderElement.

So Calling this URL from Postman:

{{protocol}}://{{host}}:{{port}}/api/pages?populate[Content][populate]=*

But since inside my HeroSliderElement are images i have the problem, that i dont get these back.

Request Detail There should be the media data linked from the CMS:

enter image description here

Does anyone have an Idea how to fix this? Any help is appreciated!

I am currently using the following versions of packages:

  "dependencies": {
"@strapi/plugin-i18n": "4.0.7",
"@strapi/plugin-users-permissions": "4.0.7",
"@strapi/provider-upload-aws-s3": "^4.1.0",
"@strapi/strapi": "4.0.7",
"pg": "8.6.0",
"strapi-provider-upload-aws-s3": "^3.6.8"

},

SupaMario
  • 998
  • 9
  • 14

3 Answers3

4

Install the official strapi plugin : strapi-plugin-populate-deep , its easy and great plugin for nested content structure, it worked for me.

Examples: Populate a request with the default max depth.

/api/articles?populate=deep

Populate a request with the a custom depth

/api/articles?populate=deep,10

Populate a request with the a custom depth

/api/articles/1?populate=deep,10
  • 1
    Whilst this plugin is great for ease of use, when building applications at scale, you don't want to be creating queries that simply grab everything. Also, you're likely to pull down something you don't want the public to see. In other words, please use it with caution. – Dallas Clark Sep 22 '22 at 04:22
  • 2
    Yes, that comes with caution! So whoever is gonna use it please use it wisely. Thanks for your valuable advice. @DallasClark – Code_Warrior Sep 29 '22 at 19:50
2

In case you're still looking for a solution, refer to answer here - Strapi V4 populate dynamic zones media not populating

Rodrigo Rubio
  • 1,686
  • 2
  • 16
  • 26
0

you need to specify every record(object, entity) at level three to fetch data from it. like as you said you want to fetch data of images from content from your this will work

{{protocol}}://{{host}}:{{port}}/api/pages?populate[Content][populate]=images

Bilal Khursheed
  • 728
  • 1
  • 5
  • 12
  • thank you for you answer. Unfortunately this does not fix my problem. The Content element is my "Zone" and one of the elements is the HeroSliderElement. And inside of the HeroSliderElement is Media. So I need to specify that the backend should return the media inside the HeroSliderElement inside the Content Zone inside the page. Do you have any idea? It would be awesome. – SupaMario Apr 01 '22 at 13:18
  • Did you end up having any luck with this? I'm facing the issue. – Rodrigo Rubio Apr 13 '22 at 12:53
  • nope @RodrigoRubio . perhaps we should open an issue. – SupaMario Apr 15 '22 at 08:18
  • 1
    @SupaMario found a work around for now, hope it helps - https://stackoverflow.com/questions/71845372/strapi-v4-populate-dynamic-zones-media-not-populating/71864626#71864626 – Rodrigo Rubio Apr 17 '22 at 10:44