I am new to contentful api. I have created link tags when i enter a url for retrieving a level 0 tag entry (a content type). I am getting the child elements id
fields": {
"level0Tag": "Problem Solving",
"level1ChildTags": [
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "4uKXvRK0veAoEuk2yAuQ2Y"
}
},
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "3QMVgykrBey8KQ2SOw8CU6"
}
}
],
"displayChildTags": true
i wish to get the name field of level 1 child tags how to get it?
when you retrieve linked entries or assets, what you get is this object with a sys property which contains metadata relative to the kind of link (in your case it tells you it's an Entry and it contains the ID). Also, at the top level of the JSON response you should get an "includes" property with an array which contains all linked assets.
By default, the API resolves the links for 1 level. If you want more than one level (or none) you can use the "include" query string parameter (such as include=2).
If you use one of the SDKs, such as the Javascript SDK, they take care of resolving these links for you in the response and replacing them with the actual object, but by default the REST API doesn't do this.
Be aware as well, that this only happens when you query a collections endpoint, such as /entries
, and not for single item endpoints such as /entries/id
.
For more information check https://www.contentful.com/developers/docs/concepts/links/ and https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/entries/entry/query-entries?console=1