Nested model attribute is null in response

System Information
  • Strapi Version: 3.6.8
  • Operating System:
  • Database: Postgres
  • Node Version: 14
  • NPM Version:
  • Yarn Version:

Hi I am having an issue with linked model attributes not populating in the response.

To further explain my issue in detail,

I have a collection type as below:

{
  "collectionName": "components_contentblocks_main_collection_type",
  "info": 
    "name": "DisplayName",
    "icon": "address-book",
    "description": ""
  },
  "options": {},
  "attributes": {
    "ComponentName": {
      "type": "component",
      "repeatable": false,
      "component": "elements.component_type"
    }
  }
}

And my element definition looks like this:

{
  "collectionName": "components_elements_component_type",
  "info": {
    "name": "DisplayNameOfType",
    "icon": "microscope",
    "description": ""
  },
  "options": {},
  "attributes": {
    ...otherAttributes,
    "nestedAttributeOfSameType": {
      "model": "model-of-main-collection-type"
    },
  }
}

nestedAttributeOfSameType comes as null in the response. However on admin console this link is visible and I can view the content from the panel. I don’t understand why this is happening because other linked model attributes populates fine without any issue. My guess is this is a nested data issue

The use case of this we have multiple articles that contain a link to another article within the same collection.


You need to populate all data what is more then 1 layer deep Populate and Select | Strapi Documentation

@Boegie19 I get this error when I try to invoke the api type?[slug]=slug-string&populate=*

{"statusCode":400,"error":"Bad Request","message":"Your filters contain a field 'populate' that doesn't appear on your model definition nor its relations"}

I also tried installing a plugin called strapi-plugin-populate-deep. That did not help either. I am trying hard not to write controllers for this and just use the out of the box features of strapi.