Content Delivery API not giving all values of Reference (many) field

Hi,

I am new to Contentful. I have Skill as one Content type which has Lessons as reference (many) field.
There are around 15-20 Lessons per skill so i have created different Content types per Lessons as each lesson has different content structure.
I have added these 15 Lessons content type as reference in Lesson field in Skill content type.

When I query the Skill content type using Content Delivery API, I am getting only 6 lessons[] per skill where as when i query using Content Management or Preview API, I am getting all 15 Lessons per skill.
Not sure why Content Delivery API not giving all lessons for skills.

Any help appreciated.

Hey @bharats,

have you made sure you published all of the linked lessons? If you get all of them in preview & management, that sounds like they are in draft state right now.

Best,
Stephan

Hi Stephan,
Thank you for your response. I just verified that all the linked lessons are in published state. Still below url returns only 6 lessons.
https://cdn.contentful.com/spaces/myspaceid/entries/myEntryid

Hi Stephan,

I think i got the problem. All Individual lessons were published but i believe the main Skill was published when there was only 6 lessons added and i added remaining lessons later and that would have created this problem. Now i just published the Skill and i started getting all lessons.

Thank you very much for your quick help.
Bharat.

1 Like

Glad to hear you found the culprit!
I think you can mark your very own reply as the “solution” - who knows it might save some minutes from someone else in the future :slight_smile:

Thank you Stephan,
I have now marked my reply as solution.

Also I have a scenario for which i need to design the content model. Is it ok if i share the same and get your opinion whether I am doing it right or not here?
Scenario is for conducting online tests:
Test1: which will have some questions and 4 options(answer), one will be correct answer
Test2: which will have some questions and 4 options(answer), user needs to select two (Most or least likely)
-Bharat

Hey @bharats,

ususally it makes sense to open a new discussion, to keep the problems scoped.

Without an example of how your content model relates, I really cannot judge whether it’s a good approach to me. In general that sounds like you’d want to have a question content type that is the wrapper around potential answers, that are linked to from the question. If answers are never shared across questions you might inline them in the content type as well, but that depends on the use-case.

For evaluating and storing the user results you’d still need your own business logic and potentially another service, Contentful is not really made for storing arbitrary users’ input. For a limited audience that might be possible with a few work-arounds (most crucial: don’t share your management token with the audience that answers the questions!)

Best,
Stephan

Hi Stephan,
Thank you for your reply. I will open a new discussion for this if required.
-Bharat