- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Publish CMS Page
SOLVEJan 14, 2020 4:32 AM - edited Jan 14, 2020 4:34 AM
I am integrating an application with the API and I encounter a difficulty when I publish pages of the website in Hubspot. I publish the page perfectly but it is being impossible for me to leave it in a state published from the API.
Can anyone guide me about this process?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Accepted Solutions
Jan 14, 2020 6:19 AM - edited Jan 14, 2020 6:20 AM
Hi @cmoraleda
This process of creating and publishing pages can be done through the use of 2 endpoints:
- Create a new page: https://developers.hubspot.com/docs/methods/pages/post_pages
- Publish or unpublish pages: https://developers.hubspot.com/docs/methods/pages/post_pages_page_id_publish_action
To walk-through this with you, i've gone ahead and created a test page using the sample JSON found in the create documentation, see below:
{ "name": "My API Page", "template_path": "hubspot_default/landing_page/basic_with_form/2_col_form_left.html" }
This is being posted to the following endpoint:
https://api.hubapi.com/content/api/v2/pages?hapikey={{hapikey}}
Once this is done, my page is created but is returned in draft mode, this is signified by the following values that are returned in your response when the page is created:
"is_draft": true,
"is_published": false,
Now, if we're looking to publish this page, we can make a new request to the following endpoint:
https://api.hubapi.com/content/api/v2/pages/PAGE_ID/publish-action?hapikey={{hapikey}}This is documented in the second link above. You'll see that this endpoint is specifically targetting the page we've just created through the use of the
page_id
which is returned in the intial response when the page is created using the above method.is_published
value set to true providing we receive the 204 No Content
status.
HubSpot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Jan 15, 2020 2:10 PM
Fixed!
I was writing the url wrong.
This is correct:
https://api.hubapi.com/content/api/v2/pages/XXXXXXXX/publish-action?hapikey=XXXXXXXXXXXXXXXXXXXX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content