includeUnpublished not working for drafts

Please fill out as many of the following questions as possible so we can help you promptly! If you don’t know how to answer or it does not apply, feel free to remove it or leave it blank.

Builder content link

Builder public api key
4ccc9312e0d14fb3b6d94d2864010b90

What are you trying to accomplish
using builder.get, we’re trying to get a draft piece of content. This comes back as undefined. When we publish the piece, we get the content. We tried using the includeUnpublished: true property here. But it had no effect.

Code stack you are integrating Builder with
We’re using NEXT.js 14. We’re using the app router with the following route:

src/app/blog/[...slug]/page.jsx
export default async function Page({ params }) {
  const urlPath = "/blog/" + (params?.slug?.join("/") || "");
  const content = await builder
    .get("article", {
      includeRefs: true,
      enrich: true,
      includeUnpublished: true,
      userAttributes: {
        urlPath,
      },
    })
    .toPromise();

  console.log(content); // This is undefined.
  return ...
}

Hi @CourseStudio,

At the content API level includeUnpublished is working, Can please confirm which SDK version you are using?

https://cdn.builder.io/api/v3/content/article?apiKey=4ccc9312e0d14fb3b6d94d2864010b90&userAttributes.urlPath=%2Fblog%2Farticle-template&limit=1&omit=data.blocks&includeUnpublished=true