[v4] How to fetch data from a collection-type?

Hi, I installed Strapi v4 beta (npx create-strapi-app@beta beta --quickstart) and tried to fetch data from a collection-type in Strapi v4 beta. Somehow I can not fetch it through http://localhost:1337/<collection-type name>.

I created a collection-type named baseball. Then I set public roles permission to allow find and findOne.

I already added data and they are published.

However, I can not get them via http://localhost:1337/baseballs.

http://localhost:1337/baseball/1 did not work too.

What was I doing wrong?

System Information
  • Strapi Version: 4.0.0.-beta-1
  • Operating System: Ubuntu
  • Database: SQLite
  • Node Version: v14.17.5
  • NPM Version: v6.14.14
  • Yarn Version: (I could not install Strapi v4 beta using Yarn)

http://localhost:1337/api/baseballs gave what I wanted.

So the solution is to add /api between port and the collection-type name :

I have the same issue, however, when I try to fetch: http://localhost:1337/api/collection-type-name

It shows me: {“data”:[],“meta”:{“pagination”:{“page”:1,“pageSize”:25,“pageCount”:0,“total”:0}}}

But if I fetch: http://localhost:1337/api/collection-type-name/1
Then it fetch my first data.

This is my ticket if you dont mind to take a look wheter my setup is correct:

you probably have draft and publish enabled and the entity isn’t published yet.

Try http://localhost:1337/api/collection-type-name?publicationState=preview

If that gives you the entities then you didn’t publish them.


Hey DMehaffy, My data is showing published in Strapi but when I run http://localhost:1337/api/collection-type-name?publicationState=preview I can still see my entities listed. Can you guide me with it. Also I am trying to use http://localhost:1337/graphql but i cannot read it. Please help me with this. It would be really helpful.

1 Like

Hey, have you found a solution ? I think I’m encountering the same problem. My content has been published but when I try and type http://localhost:1337/api/collection_type_name?publicationState=preview it only shows me the first attribute which is correct, and then it prints the dates and that is all. I’ll add a pic.
Screenshot from 2023-07-19 10-52-33