BuilderIO / BuilderIO/builder

Builder content API does not return draft content when page is already published

Open
#3,214 4 comments 3 reactions 0 assignees View on GitHub
Stale
Dominant language
TypeScript
Stars
8.8k
Forks
1.2k
Avg merge
1d 6h
Merged PRs (30d)
17

Description

**Describe the bug**
As in the title, builder content API:
https://cdn.builder.io/api/v3/content/my-model-name?apiKey=YOUR_API_KEY does not return a proper draft content when page had been already published before and then content changed. Even with includeUnpublished=true in params
![image](https://github.com/BuilderIO/builder/assets/146102269/df099b3a-459f-42de-8830-0a749accc335)

```
const req = await fetch(
`${API_V3_CONTENT}/${modelName}/${contentId}?apiKey=${appState?.user?.apiKey}&cachebust=true&cacheSeconds=5&staleCacheSeconds=5&omit=endDate,startDate&enrich=true&includeUnpublished=true`,
);
```

**To Reproduce**
Steps to reproduce the behavior:
1. create a new builder page add some custom components and click "Publish"
2. get the content with the API call
3. change some content on the page - edit some text values for example
4. do not press "Publish Updates" but try to get the content again -> old content is being returned

**Expected behavior**
New drafted content should be returned form API call

**Screenshots**
Page with some content:
**Default: "Some text"**
![image](https://github.com/BuilderIO/builder/assets/146102269/05a715b1-c357-4531-8d3e-5d5f669ca976)

Published:
![image](https://github.com/BuilderIO/builder/assets/146102269/02cfc115-dcab-4b79-a5cd-5eb424c35016)

Getting content:

https://cdn.builder.io/api/v3/content/page/fad19f47b42c43378facada257f3b8e5_ee24ce9d39d1465c85a0e8359e0c0dde?apiKey=fad19xxxxxxxxxxxxxxxxxxxxx&cachebust=true&cacheSeconds=5&staleCacheSeconds=5&omit=endDate,startDate&enrich=true
![image](https://github.com/BuilderIO/builder/assets/146102269/7b6d16a4-b37c-49e9-b3cd-9b94c76e24f5)

Changed content and not published updates:
**Default: "Some text - new content"**
![image](https://github.com/BuilderIO/builder/assets/146102269/f91c6c9a-e824-4979-85cf-7dabe6271484)

https://cdn.builder.io/api/v3/content/page/fad19f47b42c43378facada257f3b8e5_ee24ce9d39d1465c85a0e8359e0c0dde?apiKey=fad19f47bxxxxxxxxxxxxxxxxx&cachebust=true&cacheSeconds=5&staleCacheSeconds=5&omit=endDate,startDate&enrich=true

Old content returned:

![image](https://github.com/BuilderIO/builder/assets/146102269/046d82f4-5026-4377-9725-7587e84a19bb)

**Additional context**
Add any other context about the problem here.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.