API json response does not return my uploaded image

I just set up my first collection “images” which just holds images i uploaded with the media library. When i access the public api like “http://mydomain.com/api/images/1” it returns the following json:

{"data":{"id":1,"attributes":{"createdAt":"2021-12-03T10:10:04.861Z","updatedAt":"2021-12-03T10:22:20.847Z","publishedAt":"2021-12-03T10:22:20.845Z"}},"meta":{}}

Where is the image url? Why is it not returned with the get request? Every fieldtype is returned except the images…i could not find any ressources on this issue so far and it is driving me crazy.

After further investigation i found that there is no reference inside the data.db (sqlite) between the files table and images table…i suspected that would be made automatically once i create the collection type?

1 Like

I have the same problem. Did you find any solution?

I’m having this exact same problem with attributes, particilarly media files. This is the first post that I’ve seen directly related to it.

To improve performance, Strapi V4 doesn’t return media files or relation data by default. Now you have to specifically include it in your api request as is outlined in the docs -
Content API Docs.

They don’t specifically mention images in their examples, but querying for them with this method works. To just return the full response as you would have gotten in V3, you can just use /api/images/1?populate=* to have the api return all the fields.

Hope this helps!

2 Likes

Awesome - thank you for the explaination. I did not know of the (breaking?) changes from v3 to v4. Most of the videos are still on v3 where it just works out of the box. Performance wise is sound totally reasonable though.

Is there any way to populate all the images using query engine api when we have complex data structure e.g. component within component inside dynamic zone?