Skip to content

Instantly share code, notes, and snippets.

@ComfortablyCoding
Last active July 11, 2022 15:21
Show Gist options
  • Save ComfortablyCoding/defb76994c9f4e3a3ce2ade8b2a2c6c5 to your computer and use it in GitHub Desktop.
Save ComfortablyCoding/defb76994c9f4e3a3ce2ade8b2a2c6c5 to your computer and use it in GitHub Desktop.
Strapi v4 Content Type Troubleshooting

Content Type Troubleshooting

Below are common issues regarding content types and their possible solutions.

I have created a content type but receiving a 404 Not Found response

Ensure you are using the correct endpoint tense

  • Collection endpoints use their plural name. e.g. /api/posts
  • Single types use the singular name. e.g. /api/homepage

Ensure single content type is published

For single content types if draftAndPublish is enabled the response will return a 404 Not Found if the entity is not published.

I have created a content type but receiving a 401 Not Authorized response

Public Route

For routes that should be discoverable to the public the following must be true:

  • find is checked in the following location Settings -> [User and Permissions] Roles -> Public -> Respective Content Type.
  • No Authorization header is being sent with the request.

Authorized Route

For routes that should be discoverable to authorized users only the following must be true:

  • find is checked in the following location Settings -> [User and Permissions] Roles -> Authenticated -> Respective Content Type.
  • A valid Authorization header is being sent with the request.

I am not receiving anything in my collection response

By default Strapi only returns published records, navigate to the respective content type and Publish a record. Retriggering the request should now return the newly published record.

If you want the records returned irrespective of publication state their is an example in the strapi docs on how to do so in the green tip area.

I have added a relation/component/image to my content type but it is not showing in the response

By default relations,components and images are not populated on the request. To have them returned in the request the populate parameter is required.

I am using populate for my content type but the relation is still not showing

Ensure that the user making the request has access to the relation content type. You can do so by going to the following location Settings -> [User and Permissions] Roles -> Relevant user role (i.e Public or Authenticated) -> Respective Content Type and confirming that find/findOne are enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment