Cannot see media field in my endpoint for my content type

@bruceg

l have managed to find the answer!

In order to get the image attributes you now have to specify the field for your media in the endpoint. Therefore my new url ended up with this:

http://localhost:1337/api/notifications?populate=image

And the response:

{
"id": 1,
"attributes": {
"title": "Testing",
"createdAt": "2021-12-03T16:04:09.535Z",
"updatedAt": "2021-12-03T16:20:36.636Z",
"publishedAt": "2021-12-03T16:04:10.329Z",
"image": {
"data": {
"id": 1,
"attributes": {
"name": "photo1.jpg",
"alternativeText": "photo1.jpg",
"caption": "photo1.jpg",
"width": 5024,
"height": 3203,
"formats": {
"thumbnail": {
"name": "thumbnail_photo1.jpg",
"hash": "thumbnail_photo1_459714b552",
"ext": ".jpg",
"mime": "image/jpeg",
"width": 245,
"height": 156,
"size": 13.06,
"path": null,
"url": "/uploads/thumbnail_photo1_459714b552.jpg"
},
"large": {},
"medium": {},
"small": {}
},
"hash": "photo1_459714b552",
"ext": ".jpg",
"mime": "image/jpeg",
"size": 1487.27,
"url": "/uploads/photo1_459714b552.jpg",
"previewUrl": null,
"provider": "local",
"provider_metadata": null,
"createdAt": "2021-12-03T16:03:55.072Z",
"updatedAt": "2021-12-03T16:03:55.072Z"
}
}
}
}
}

Hope others find this useful!

4 Likes