Updating a batch of landing pages

AChou44
Member

Hi there, I am currently trying to use this endpoint: https://developers.hubspot.com/docs/api-reference/cms-pages-v3/landing-pages/post-cms-v3-pages-landi... to batch update landing pages. I am trying to update values of a custom module (simply toggling a Boolean field in that module) for multiple landing pages.

 

The problem I'm running into, as per the (limited) documentation on that page, the payload is an array of JSON objects that contains the fields to be updated. This works, I can provide the correct id and the correct JSON to update the widgets portion of the landing page. However, it seems that if I do not provide the data for the other modules (widgets) as well in my payload, it will delete that data from the page. The solution I can think of is to make a batch retrieve for the same landing pages, paste that JSON into the payload for the batch update and simply modify the parts I need to in that JSON.

 

I want to know if there is a different endpoint/method that can make this easier? I am concerned that I will accidentally delete things from my landing pages that I neglected to include in the payload for the batch update endpoint, as there doesn't seem to be any checks on HubSpots end.

 

 

0 Upvotes
1 Accepted solution
evaldas
Solution
Recognized Expert | Platinum Partner
Recognized Expert | Platinum Partner

Hi @AChou44,

 

You are on the right path thinking about retrieving existing pages first. 

 

When updating a page, the payload is meant to communicate what the contents of the page should be, so if you include only the custom module in the payload, only the custom module will show on the page if updated via API. The payload overrides anything that was previously on the page.

 

According to the API reference, partial updates to a page are not supported.

 

Your best bet is retrieving the page via API first, making the necessary tweaks to that retrieved JSON and then send that updated JSON as the payload. 

✔️ Did this post help answer your query? Help the community by marking it as a solution.

View solution in original post

0 Upvotes
1 Reply 1
evaldas
Solution
Recognized Expert | Platinum Partner
Recognized Expert | Platinum Partner

Hi @AChou44,

 

You are on the right path thinking about retrieving existing pages first. 

 

When updating a page, the payload is meant to communicate what the contents of the page should be, so if you include only the custom module in the payload, only the custom module will show on the page if updated via API. The payload overrides anything that was previously on the page.

 

According to the API reference, partial updates to a page are not supported.

 

Your best bet is retrieving the page via API first, making the necessary tweaks to that retrieved JSON and then send that updated JSON as the payload. 

✔️ Did this post help answer your query? Help the community by marking it as a solution.

0 Upvotes