joshuak
joshuak

Reputation: 103

Why does Contentful Delivery API sometimes return Child References as type "Link" rather than "Entry" after 3-4 weeks?

After 3-4 weeks, when fetching Contentful data via Contentful Delivery API, I noticed that most child references show up as "type": "Link" instead of "type": "Entry" so all the child fields are missing (causing us issues when accessing child fields).

JSON with issue

{
  "sponsors": {
    "metadata": {},
    "sys": {},
    "fields": {
      "entryTitle": "SPONSORS",
      "display": true,
      "heading": "SUPPORTED BY OUR SPONSORS",
      "articles": [
        {
          "sys": {
            "type": "Link",
            "linkType": "Entry",
            "id": "aaabbbccc"
          }
        }
      ]
    }
  }
}

Notice the child "articles" is "type": "Link" and missing "fields".

Expected JSON
You should see "artcles" > "fields" object:

{
  "sponsors": {
    "metadata": {},
    "sys": {},
    "fields": {
      "entryTitle": "SPONSORS",
      "display": true,
      "heading": "SUPPORTED BY OUR SPONSORS",
      "articles": [
        {
          "metadata": {},
          "sys": {
            "space": {},
            "id": "aaabbbccc",
            "type": "Entry",
            "createdAt": "2023-12-11T15:29:35.122Z",
            "updatedAt": "2024-07-01T12:59:34.345Z",
            "environment": {},
            "revision": 4,
            "contentType": {
              "sys": {
                "type": "Link",
                "linkType": "ContentType",
                "id": "article"
              }
            }
          },
          "fields": {
            "entryTitle": "SUPPORTED BY OUR SPONSORS ARTICLE #1",
            "thumbnail": {}
          }
        }
      ]
    }
  }
}

Side by side screenshot: left json with child as link; right json with child as entry with fields

To fix the JSON fetch so it returns all child fields we need to go to "References" tab in Contentful's Entry and "Select All", and then "Publish all". This magically refreshes all "Links" to show full Entry details as shown on right side of screenshot above.

QUESTION 1) Does anyone know if Contentful has some sort of expiration date on Entries/References that causes this issue, and what that timing is?

QUESTION 2) And better, is there a configuration in Contentful.com or via Contentful APIs that makes sure these references do not "expire" (if that is such a thing) so we can always fetch the full JSON data with all child entries/fields?

Thank you 🙏!

Upvotes: 0

Views: 165

Answers (0)

Related Questions