APIs & Integrations

cmoraleda
Miembro

Publish CMS Page

resolver

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?

0 Me gusta
2 Soluciones aceptadas
Willson
Solución
HubSpot Employee
HubSpot Employee

Publish CMS Page

resolver

Hi @cmoraleda 

 

This process of creating and publishing pages can be done through the use of 2 endpoints:

  1. Create a new pagehttps://developers.hubspot.com/docs/methods/pages/post_pages
  2. Publish or unpublish pageshttps://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.
 
Once this is sent, the page we've just created will be updated and the is_published value set to true providing we receive the 204 No Content status. 

I hope this helps!

 

Product Manager @ HubSpot

Ver la solución en mensaje original publicado

0 Me gusta
cmoraleda
Solución
Miembro

Publish CMS Page

resolver

Fixed!

I was writing the url wrong.

 

This is correct:

https://api.hubapi.com/content/api/v2/pages/XXXXXXXX/publish-action?hapikey=XXXXXXXXXXXXXXXXXXXX

Ver la solución en mensaje original publicado

4 Respuestas 4
Willson
Solución
HubSpot Employee
HubSpot Employee

Publish CMS Page

resolver

Hi @cmoraleda 

 

This process of creating and publishing pages can be done through the use of 2 endpoints:

  1. Create a new pagehttps://developers.hubspot.com/docs/methods/pages/post_pages
  2. Publish or unpublish pageshttps://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.
 
Once this is sent, the page we've just created will be updated and the is_published value set to true providing we receive the 204 No Content status. 

I hope this helps!

 

Product Manager @ HubSpot
0 Me gusta
cmoraleda
Miembro

Publish CMS Page

resolver

Thanks for your answer!

I have performed the steps you comment and the answer has been this:

 

HTTP ERROR 405

Problem accessing /cospages/v1/pages/XXXXXXXX/push-buffer-live. Reason:

Method Not Allowed

 

To publish I used this url:

https://api.hubapi.com/content/api/v2/pages/XXXXXXXX/push-buffer-live?hapikey=XXXXXXXXXXXXXXXXXXXX 

0 Me gusta
cmoraleda
Solución
Miembro

Publish CMS Page

resolver

Fixed!

I was writing the url wrong.

 

This is correct:

https://api.hubapi.com/content/api/v2/pages/XXXXXXXX/publish-action?hapikey=XXXXXXXXXXXXXXXXXXXX

Willson
HubSpot Employee
HubSpot Employee

Publish CMS Page

resolver

Hi @cmoraleda 

 

Great, glad to hear this is working for you now!

Product Manager @ HubSpot
0 Me gusta