Delivery API not returning fields on linked entries with javascript sdk v5.1.3
- Node Version: v8.9.0
- Npm Version: 5.5.1
- Platform: Darwin la-jsirota-mbp 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64
- Package Version: [email protected]
We have a set of linked values in entries and we expect the fields from second level the linked entries to appear when we set include=2
When using the preview api, the fields appear, however when using the delivery api, the fields are not included.
Preview API call:
https://preview.contentful.com/spaces/[space id]/entries?content_type=section&fields.slug=registration-form&locale=en-US&include=2
Preview API JSON result (with fields in links)
“fields”: {
“title”: “Registration Form”,
“slug”: “registration-form”,
“text”: “",
“stringProperties”: [{
“sys”: {
“space”: {
“sys”: {
“type”: “Link”,
“linkType”: “Space”,
“id”: “[space id]”
}
},
“type”: “Entry”,
“id”: “[entry id]”,
“contentType”: {
“sys”: {
“type”: “Link”,
“linkType”: “ContentType”,
“id”: “property”
}
},
“revision”: 1,
“createdAt”: “2018-02-16T00:06:28.789Z”,
“updatedAt”: “2018-03-13T23:54:15.744Z”,
“locale”: “en-US”
},
**“fields”: {
“key”: “exampleKey”,
“value”: “Example Text”
}**
}
Delivery API call:
https://cdn.contentful.com/spaces/[space id]/entries?content_type=section&fields.slug=registration-form&locale=en-US&include=2
Delivery API JSON result (without fields in links)
"fields": {
"title": "Registration Form",
"slug": "registration-form",
"text": "By joining Baby Box University, you agree to the [Terms of Service](/terms-of-service) and [Privacy Policy](/policy) of The Baby Box Company.",
"stringProperties": [
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "[link id]"
}
},
**//no fields in stringProperty, just sys**
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "[link id]"
}
},
This seems to be the reverse of this issue: https://github.com/contentful/contentful.js/issues/104
Hey Jason,
there might be multiple reasons why your delivery response does not contain the linked entries and just the links.
First of all, are you sure that the linked entries are published?
If they are, can you please check the following in the response while using the delivery api:
- Is your entry included in the includes array
getEntries().then(response => console.log(response.includes))? (If yes, there is an issue with our SDK's link resolution) - Did the API response contain any errors? Check it via
getEntries().then(response => console.log(response.errors))
All the best, Benedikt
@axe312ger
I came across this issue as well.
✓ linked entries are published
Is your entry included in the includes array getEntries().then(response => console.log(response.includes))? (If yes, there is an issue with our SDK's link resolution)
Seems to be the case for me.
✓ no response.errors
"contentful": "5.1.3",
❯ node -v && npm -v
v9.6.0
5.7.1
Hmm, sounds more and more like a SDK bug. Can one of you please provide me a full response as JSON so I can actually test this with real data?
If the response contains confidential information, please open a support ticket via https://www.contentful.com/support/ including the full response data and a link to this issue to make sure it ends up at my desk.
Thank you
I'm experiencing the same issue. But only with getEntry. getEntries works fine for me.
Will send a support ticket with the info I have.
Concerning @tleunen's comment, his issue is different. We've already resolved it in a support ticket but if users want to use the include parameter for just one entry, the request URL needs to be structured like this (with the sys.id for the entry):
https://cdn.contentful.com/spaces/<spaceID>/entries?access_token=<token>&include=2&sys.id=<entryID>
@tleunen getEntry does not support resolving linked fields due to API limitations. Please use getEntries and simply filter by sys.id=<entry_id> (Thats actually exactly what Christine said, she just pointed out the plain http way)
See -> https://github.com/contentful/contentful.js#link-resolution