向Google Calendar ACL添加域名时遇404 Domain not found错误求助
Let's break down how to fix this 404 issue you're facing—here are practical steps to test and resolve it:
Double-check your POST request URL and calendar ID
Make sure the calendar ID in your POST URL (myid@resource.calendar.google.com) is exactly the same as the one you use for the successful GET request. You can verify this ID in the Google Calendar web app: go to the resource calendar's Settings and sharing > Calendar address to confirm the unique ID. A tiny typo here can easily trigger a 404.Validate your request method and headers
For this ACL insert operation, ensure:- You're using the POST HTTP method (not GET/PUT)
- Your request includes the header
Content-Type: application/json
Missing the content-type header or using the wrong method is a common cause of misleading 404 errors, as the API can't properly parse your request body.
Verify your OAuth token's scope
The OAuth token you're using to send the API request must include eitherhttps://www.googleapis.com/auth/calendarorhttps://www.googleapis.com/auth/calendar.aclpermissions. Sometimes insufficient scope can manifest as a "Not Found" error instead of a clear permission denial. You can check your token's scopes using an OAuth debugging tool, or re-authorize your app to ensure you've selected the correct calendar ACL permissions.Fix the domain format in your request body
Ensure you've removed the angle brackets from the domain value. Your request body should look like this:{ "scope": { "type": "domain", "value": "example.com" }, "role": "freeBusyReader" }Leaving
<>in the domain string will make the API unable to recognize the domain, leading to a 404.Test adding the ACL via the Google Calendar web app first
Since you have full admin access, try manually adding the domain rule in the web interface:- Go to the resource calendar's Settings and sharing
- Under Share with specific people, enter
domain:yourdomain.com - Set the permission to See only busy/free (hide details)
If this works, the issue is isolated to your API request setup. If it fails, there might be a global G Suite setting blocking external domain sharing for resource calendars.
You can also use the Google API Explorer to test the calendars.acl.insert method directly—this tool will handle auth headers and formatting for you, and may return more specific error details than your custom request.
内容的提问来源于stack exchange,提问作者Jeroen Maelbrancke

