Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Content Layer
namePage Info
id821023944
classwatermark-layer
Content Column
namePage Body
width100.00002%
id821023946
Content Block
background-colortransparent
namePrompt
rich-link-hoverstrue
id821023943
classtight reference-prompt-flex

Create spaces and pages from Blueprints programmatically using the REST API.

Content Block
nameReference
rich-link-hoverstrue
id1434454811
classpage-pattern-heading reference-reference-flex

REST API Requirements

REST API endpoints were added to Blueprint Maker version 2.0+ to allow:

  1. creating new content using a defined blueprint (page, page tree, or space, as defined by the blueprint)
  2. updating an existing page using a defined blueprint (single page blueprints only)

These will function the same as if a creating a Blueprint from the Blueprint Maker wizard menu.

 

The Blueprint Maker REST API can be used in conjunction with the existing Confluence REST API. For example, 

Open Links in New Window
 

REST API Usage

Requests
Code Block
languagetext
PUT /rest/blueprintmaker/1.0/createspace (create new space)
PUT /rest/blueprintmaker/1.0/createpage (create new page)
POST /rest/blueprintmaker/1.0/updatepage/{pageid} (recreate an existing page)
PUT /rest/blueprintmaker/1.0/copyspace (copy space)
PUT /rest/blueprintmaker/1.0/copypage (copy page)
Data
Code Block
languagejs
{
	"blueprint" : {
		"name" : "Blueprint name"				// not required for copyspace and copypage
	},
	"source" : {								// only for copypage and copyspace
		"spaceKey" : "sourceSpaceKey",
		"pageTitle" : "Source Page Title"		// only for copypage
	},
	"destination" : {							// if not specified for copypage, new page will be a sibling to the source page
		"pageId" : "1234567",					// if specified, spaceKey and pageTitle will be ignore for calculating destination page
												// ignored for updatepage
		"spaceKey" : "destinationSpaceKey",
		"spaceName" : "New Space Name",			// required for createspace and copyspace
		"spaceDescription" : "Space Blurb",		// optional, only for createspace and copyspace
		"pageTitle" : "Destination Page Title",
		"parentPageTitleId" : "1234567"			// optional: defaults to destination space home page for createpage
		"parentPageTitle" : "Parent Page"		// optional: defaults to destination space home page for createpage
												//			 defaults to parent of source page for copypage
												//			 ignored if parentPageTitleId is specified
	},
	"fields" : [								// values to substitute for blueprint fields
		"field1" : "value",
		"field2" : "value"
	]
}
Responses

Status
colourGreen
titleStatus: 200
 - application/json

Code Block
languagejs
{
	"pageId" : 1234567	// page ID of single page created or updated, or root of page tree, or space home page
}

Status
colourRed
titleStatus: 403
 - Caller lacks permission to edit/create pages in the destination space, or a multi-page blueprint was specified (PUT request)

Status
colourRed
titleStatus: 404
 - The specified blueprint, destination page (PUT request), or destination parent page doesn't exist or caller lacks view permission

 

JavaScript Examples (jQuery)

Create Space
Code Block
languagejs
var data = {
	blueprint: {
		name: "Project Space"
	},
	destination: {
		spaceKey: "sunset",
		spaceName: "Sunset Hills",
		spaceDescription: "Everything you need to know about the Sunset Hills project."
	},
	fields: [
		{
            name: "project-name",
            value: "Sunset Hills"
        },
        {
            name: "location",
            value: "432 West Elm"
        }
	]
};
$.ajax({ 
	url: "/rest/blueprintmaker/1.0/createspace", 
	data : JSON.stringify(data), 
	type: "PUT", 
	success: function(r) {console.log(r);}, error: function(x,s,t) {console.log(x,s,t);}, 
	dataType: "json"
});
Create Page
Code Block
languagejs
var data = {
    blueprint: {
        name: "Project Page"
    },
    destination: {
        spaceKey: "project",
        pageTitle: "Project [[project-number]] - [[project-name]]",
        parentPageTitle: "Projects Home"
    },
    fields: [
        {
            name: "project-number",
            value: "23445"
        },
        {
            name: "project-name",
            value: "Sunset Hills"
        },
        {
            name: "location",
            value: "432 West Elm"
        },
        {
            name: "site-manager-name",
            value: "Susan Clarke"
        },
        {
            name: "site-manager-phone",
            value: "(123) 555-4433"
        },
        {
            name: "completion-date",
            value: "11/30/2019"
        }
    ]
};
$.ajax({
    url: "/rest/blueprintmaker/1.0/createpage",
    data : JSON.stringify(data),
    type: "PUT",
    success: function(r) {console.log(r);}, error: function(x,s,t) {console.log(x,s,t);},
    dataType: "json"
});
Update Page
Code Block
languagejs
curl -u admin:admin -X POST -H "Content-Type: application/json" -d '{"blueprint": {"name": "Project Page"}, "destination": {"pageTitle": "Project [[project-number]] - [[project-name]]"}, "fields": [{"name": "project-number", "value": "23445"}, {"name": "project-name", "value": "Sunset Vista"}, {"name": "location", "value": "432 West Elm"}, {"name": "site-manager-name", "value": "Susan Hitcheson"}, {"name": "site-manager-phone", "value": "(123) 555-4433"}, {"name": "completion-date", "value": "12/31/2019"}]}' http://localhost:8090/rest/blueprintmaker/1.0/updatepage/139526161

Copy Space
Code Block
languagejs
var data = {
	source: {
		spaceKey: "sunset"
	},
	destination: {
		spaceKey: "seaside",
		spaceName: "Seaside Project",
		spaceDescription: "Everything you need to know about the Seaside project."
	}
};
$.ajax({ 
	url: "/rest/blueprintmaker/1.0/copyspace", 
	data : JSON.stringify(data), 
	type: "PUT", 
	success: function(r) {console.log(r);}, error: function(x,s,t) {console.log(x,s,t);}, 
	dataType: "json"
});
Copy Page
Code Block
languagejs
var data = {
	source: {
		spaceKey: "sunset",
		pageTitle: "Sunset Information"
	},
	destination: {
		spaceKey: "sunset",
		pageTitle: "Sunset Site Details"
	}
};
$.ajax({ 
	url: "/rest/blueprintmaker/1.0/copypage", 
	data : JSON.stringify(data), 
	type: "PUT", 
	success: function(r) {console.log(r);}, error: function(x,s,t) {console.log(x,s,t);}, 
	dataType: "json"
});
Content Layer
background-color$lightGrayColor
nameRelated
id1407948505
Content Column
nameRelated
width100%
id1407948506
Content Block
rich-links-hide-descriptiontrue
rich-links-hide-site-namefalse
rich-link-hoverstrue
rich-links-columns4
rich-links-verticaltrue
rich-links-image-height100px
rich-links-hide-site-icontrue
rich-links-details-padding10px
nameRelated
rich-links-enabletrue
rich-links-details-alignmentleft
rich-links-margin20px 30px 0 0
id833591344
classrelated-block clean reference-related-flex