APIs & Integrations

nclsmitchell
Member

Creating Landing Page through API via template

Hello,

 

I need to create Landing Page through the Hubspot API using an existing template.

 

I already tried to create a new page via the following request: https://developers.hubspot.com/docs/methods/pages/post_pages

 

But I am obtaining a blank page in return. It seems that the reason it is created blank is because I have no content as widgets in the JSON payload I am using to create the new page.

 

That is why I would like to know where, from an existing template, I can find a corresponding JSON payload example in order to create a non empty landing page.

 

Thank you in advance,

 

 

Nicolas

0 Upvotes
4 Replies 4
DShah3
Member

Creating Landing Page through API via template

@WendyGoh How can i get template_path and different 

"module_1561022975876100"
0 Upvotes
WendyGoh
HubSpot Employee
HubSpot Employee

Creating Landing Page through API via template

Hi @nclsmitchell,

 

I hope all is well with you 😄

 

When looking to create a page with content, you would first need to ensure that the template path is pointing to a template with content widgets. Next, I'd suggest for you to use this endpoint: Get a Page by ID | COS Page Publishing API so that you can easily have an idea of what to include in the widget/widget containers property so that moving forward when you're updating the page or creating another page, you may include the widget/widget containers property so that the page isn't blank.

 

An example of a code that works for me:

{
	"name": "My API Page2",
	"template_path": "generated_layouts/7386741250.html",
	"widgets": {
		"logo": {
			"body": {
				"alt": "",
				"height": -1,
				"link": "{{link of page}}",
				"override_inherited_src": false,
				"width": -1
			},
			"child_css": {},
			"css": {},
			"id": "logo",
			"label": "Logo",
			"name": "logo",
			"order": 0,
			"type": "logo"
		},
		"module_1561022975876100": {
			"body": {
				"field_types": {},
				"module_id": 8366491,
				"path": "/Marketplace/www.hubspot-site-setup.com/Vast_Site_Setup/Templates/onformhstestmodule",
				"per_widget_wrapper_html": "",
				"smart_type": "NOT_SMART",
				"tag": "module",
				"type": "module",
				"widget_name": "onformhstestmodule",
				"wrap_field_tag": "div",
				"wrapping_html": ""
			},
			"child_css": {},
			"css": {},
			"id": "module_1561022975876100",
			"label": "onformhstestmodule",
			"module_id": 8366491,
			"name": "module_1561022975876100",
			"order": 2,
			"type": "module"
		},
		"right_column": {
			"body": {
				"html": "<h2>hello test</h2>"
			},
			"child_css": {},
			"css": {},
			"id": "right_column",
			"label": "Right Column",
			"name": "right_column",
			"order": 3,
			"type": "rich_text"
		},
		"section_header": {
			"body": {
				"header": "Inbound Marketing",
				"subheader": "Will take you to new ground"
			},
			"child_css": {},
			"css": {},
			"id": "section_header",
			"label": "Section Header",
			"name": "section_header",
			"order": 1,
			"type": "section_header"
		},
		"social_sharing": {
			"body": {},
			"child_css": {},
			"css": {},
			"id": "social_sharing",
			"label": "Social Sharing",
			"name": "social_sharing",
			"order": 4,
			"type": "social_sharing"
		}
	}
}

Hope this helps to clarify!

0 Upvotes
nclsmitchell
Member

Creating Landing Page through API via template

Hello @WendyGoh,

 

Thank you for your response, I also tried to ad the "widget" content in my JSON payload while creating the new page.

 

Still I have an error with the template, I want to use one on path "template_path": "Marketplace/Neambo/Act21/Templates/Act21 LP 1 Col Hero.html", but I get the error in my newly created page settings (see screenshot).

 

Would it be possible to send you an e-mail with all the links of the page and template used so you may investigate the issue?

 

Thank you in advance,

 

Best regards,

 

 

NicolasCapture d’écran 2019-09-15 à 19.44.39.jpg

0 Upvotes
WendyGoh
HubSpot Employee
HubSpot Employee

Creating Landing Page through API via template

Hi @nclsmitchell,

 

Sure! In this case, could you send over your portal ID as well as the details that you'd like to share over via DM?

0 Upvotes