Getting 404 error when trying to fetch published Google Docs via API

I can read Google Docs from my personal drive without issues, but I’m stuck with published documents. When I make the document public and try to fetch it using the published URL, I keep getting this error:

HttpError 404 when requesting https://docs.googleapis.com/v1/documents/2PACX-1vSHesOf9hv2sPOntssYrEdubmMQm8lwjfwv6NPjjmIRYs_FOYXtqrYgjh85jBUebK9swPXh_a5TJ5Kl?alt=json returned "Requested entity was not found."

I’ve tried different permission settings for my service account and various ways to format the document ID but nothing works. My goal is to extract the JSON content from the published document so I can process the data. Has anyone successfully accessed published Google Docs through the API?

Published docs don’t work with the API because Google treats them like static web pages, not API resources. When you publish a doc, Google makes a read-only snapshot with that 2PACX ID, but the Docs API only works with the original document IDs from Drive. I ran into this exact issue building a document processor for client reports. Here’s what works: keep the docs private, share them directly with your service account’s email, then use the original document ID from the Drive URL. You’ll get full API access and can pull the JSON data you need.

The problem is how Google Docs handles published documents—they become separate entities that the API can’t work with. When you publish a doc, it creates a static HTML version with that 2PACX identifier, and the API doesn’t recognize it at all. I ran into this same issue building a documentation sync system. You need to stick with the original document ID from Drive and make sure your service account has viewer access to that doc. Don’t try using the published URL for API calls—it won’t work.

Indeed, the Google Docs API can be quite tricky with published documents. The published URLs, which start with 2PACX, are designed for web access, but the API doesn’t recognize them as valid input. Instead, it requires the original document ID that you can find in the URL when you view the document in your Google Drive. If you keep the document private, it’s best to share it with the service account directly. This allows for seamless API access without the complications of the published version, ensuring you can extract the content you need.

This ID confusion happens constantly. You’re dealing with two systems that don’t work well together.

I hit this exact problem building a content pipeline for our marketing team. They’d publish docs expecting our automation to pick them up automatically. Wasted tons of time on service account permissions and API endpoints.

I ended up automating everything with Latenode. Instead of fighting Google Docs API directly, I built a scenario that watches our shared Drive folder, processes new documents automatically, pulls the content, and formats it how we need it. No more ID headaches or permission issues.

Latenode handles authentication behind the scenes. Connect your Google account once and you’re done. You can also chain it with other tools to process that data further.

Much cleaner than writing custom code for Google’s weird API quirks. Check it out at https://latenode.com

Everyone’s right about the ID mismatch, but there’s a simpler approach.

I hit this same wall when our content team needed automated doc processing. Wasted days on service account permissions and figuring out which ID goes where.

Then I realized I was overcomplicating it. Built a workflow in Latenode that connects directly to Google Docs - no API headaches. It watches folders, grabs content automatically, and exports data however you need.

No more ID confusion or service account setup. Connect your Google account, tell it which docs to monitor. It handles authentication behind the scenes.

You can trigger actions when docs get updated or published. Way cleaner than writing custom code for Google’s quirky API.

Check it out at https://latenode.com

Yeah, this is super common. The published document ID (the one starting with 2PACX) isn’t what the API wants - it needs the original document ID. When you publish a doc, Google creates a different ID for the public version, but the API still looks for the original one. Just grab the real ID from your original document URL in Drive - it’s that long string between ‘/document/d/’ and ‘/edit’. Use that ID and you should be good, assuming your service account has read permissions. I hit this exact same wall last year and wasted hours on it before figuring out the ID mix-up.

Had this exact problem a few months back. Google Docs API won’t work with those 2PACX published IDs - it’s like trying to use a movie ticket to board a plane. You need to use the original document ID and give your service account direct access to the doc instead of the published version.