403 forbidden response when patching only some pages

Hello all, I am currently creating a script to move content from an old widget module to a new widget module for essentially all site-pages.

I am running into an issue actually patching certain pages when running the script, when I attempt to patch the first page with this raw json:

https://api.hubapi.com/cms/v3/pages/site-pages/187322196745

{

"widgets": {

        //widget data here...

}

}

I get the following response:

403 Forbidden

{

"correlationId": "ff5f9cb5-7dc3-4200-86a5-8f6e7eb49070",

"message": "There was a problem with the request.",

"status": "error"

}

and when I take the exact same json and patch a different page:

https://api.hubapi.com/cms/v3/pages/site-pages/197783187288

I get a 200 response as I have for every other page I have tested on

I have triple checked that the integration has the content scope added.

Both pages in this example are published, the instance does not have a content approval enabled for anything, and it doesn’t have access to workflows as its not enterprise.

I have not been able to find any permission related things that would prevent it for this page specifically although all the permissions i have seen are related to users rather than integrations so I am drawing a blank.

For the issue page, I am able to update the draft version of the page although i haven’t confirmed that i can publish the page after doing so as I would prefer to work around publishing pending content.

Please let me know if any additional information is required.

Hi @MLeszczynski7,
Thank you for posting to the Community!
I’d like to tag in some Top Contributors to see if they have any suggestions here -- Hi @nickdeckerdevs1 @Bortami and @eburnaman Do any of you all have any tips for @MLeszczynski7?
Cassie, Community Manager

Have you tried cloning the page you’re having the issue with and then trying it out with that cloned page?

Without knowing what you’re actually doing, this is gonna be a little bit more difficult for me to help you with this. So I’m gonna make an assumption on what I think you’re doing, or how I would approach this, and maybe this aligns.

If I was looking to replace a module on a website page across a bunch of pages, my script would probably be looking for that specific widget, and then doing like a regex replace on that widget.

So what I would do is get the page via the API, I would then search for that widget in the content, then I would do the regex replace, Then update the page via the api.

Something you could do here is verify that the json is valid, Could be possible that the json is malformed after making the update.

The next things I would be looking at if I was working on this is I would load up the page in the editor and determine what is different about that page from the other pages that have worked correctly and see if there are some outlier that is going to prevent this from working correctly and troubleshoot around that.

And if this is just a one off issue, you could easily go into the page editor, and save this New widget area that you are updating, save that as a new section and then load that section on that page that is giving you a problem.

Overall, without a lot more details from you, I’m not sure how much more I can help you out with this, let me know!

hey @nickdeckerdevs1, thank you for the reply.

So I am able to take the EXACT json (that was meant for the page being an issue) and use it in a patch request for another test page, and it works fine with a 200 OK response (the widget gets updated properly as well). so I don’t think the JSON being malformed is the issue here.

Also I recieve an error when cloning the page, so that may have something to do with it.

I suppose a better question would be, what could be causing this page specifically to return 403 forbidden? As you mentioned :

“The next things I would be looking at if I was working on this is I would load up the page in the editor and determine what is different about that page from the other pages that have worked correctly”

any ideas on what to look out for? all the permissions ive seen have been related to users and not to integrations so I am at a loss.

If this is just a one off issue I’m not worried about it, but i would like to know what the issue is so that i can tell how many pages this will affect.

Thanks,