How can I create page in confluence?

I manage to create a draft and publish it, but I want to publish the page right away without creating a draft and I get an error : Attempted to create a page that needs to go to the editor.

	CreateBlueprintPageRestEntity entity = new CreateBlueprintPageRestEntity(
				params.get("typeSelect").toString(),
				this.getAnnounceBlueprint(params).getId().toString(),
				"",
				"",
				params.get("departmentSelect") + ". " + params.get("subject").toString(),
				"",
				0,
				"",
				this.getContext(params)
		);

		BlueprintPage content1 = this.contentBlueprintService.createPage(
				entity,
				AuthenticatedUserThreadLocal.get()
		);


		String baseUrl = this.settingsManager.getGlobalSettings().getBaseUrl();

		PageEntity blpentity = new PageEntity(content1, baseUrl);


		return blpentity.getUrl();```

Hi Alex,

Do you use Script Runner for Confluence? If so, you could you the following:

import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.spaces.Space
import com.atlassian.confluence.spaces.SpaceManager
import com.atlassian.confluence.pages.templates.PageTemplateManager
import com.atlassian.confluence.core.DefaultSaveContext
import com.atlassian.confluence.pages.Page
import com.atlassian.confluence.pages.PageManager
import com.atlassian.sal.api.ApplicationProperties
import com.atlassian.confluence.pages.Page
import com.atlassian.sal.api.component.ComponentLocator

def pageManager = ComponentLocator.getComponent(PageManager)
def spaceManager = ComponentLocator.getComponent(SpaceManager)
def pageTemplateManager =ComponentLocator.getComponent(PageTemplateManager)

def parentPage = pageManager.getPage(ID OF PARENT PAGE)

def space = parentPage.getSpace()

def template1 = pageTemplateManager.getPageTemplate(ID OF TEMPLATE).getContent()

def new_page = new Page(title: “This is the title” , bodyAsString: template1 ,space: space, parentPage: parentPage)
pageManager.saveContentEntity(new_page, DefaultSaveContext.DEFAULT)
parentPage.addChild(new_page)
pageManager.saveContentEntity(new_page, DefaultSaveContext.MINOR_EDIT)