Skip to content

Relations are not populated if API key is read-only #11920

@ovlb

Description

@ovlb

Bug report

Describe the bug

In v4.0.0 relations inside API responses do not show up if the API key is set to «read-only». For this it does not matter how the populate query param is formatted (e.g. populate=* or populate[0]=authors&populate[1]=categories). This solution for deeply nested relations does not work either.

The only solution so far is to set the type of the API key to «Full Access». While this might be fine in some circumstances, it is not in other. (E.g. I’m currently building an 11ty site with Strapi as a CMS and the 11ty build should only have read access.

Steps to reproduce the behavior

  1. Go to Settings ->
  2. Create a new API key with read-only permissions
  3. Create a new model w/ some relations (the restaurant example from the docs or this one).
  4. Request the page in Paw or another API client, using the API token, and the populate=* query param
  5. Relations are not showing up

Expected behavior

Relations should be populated

Screenshots

Figure 1: API response with a read-only API key

Figure 2: API response with a full access API key (expected behaviour)

System

  • Node.js version: v14.5.0/v16.13.1
  • NPM version: v6.14.5/v.8.1.2
  • Strapi version: v4.0.0
  • Database: Postgres
  • Operating system: macOS/Ubuntu

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue: bugIssue reporting a bugseverity: highIf it breaks the basic use of the productsource: core:strapiSource is core/strapi packagestatus: confirmedConfirmed by a Strapi Team member or multiple community members

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions